Zelda Classic Coverage Report


Directory: src/
File: src/zc/zc_sys.cpp
Date: 2023-04-14 05:35:34
Exec Total Coverage
Lines: 1774 4259 41.7%
Functions: 128 346 37.0%
Branches: 957 2716 35.2%

Line Branch Exec Source
1 //--------------------------------------------------------
2 // Zelda Classic
3 // by Jeremy Craner, 1999-2000
4 //
5 // zc_sys.cc
6 //
7 // System functions, input handlers, GUI stuff, etc.
8 // for Zelda Classic.
9 //
10 //--------------------------------------------------------
11
12 // to prevent <map> from generating errors
13 #define __GTHREAD_HIDE_WIN32API 1
14
15 #include "precompiled.h" //always first
16 #include "zc_sys.h"
17
1/2
✓ Branch 0 taken 31 times.
✗ Branch 1 not taken.
31
18 #include <stdio.h>
19 #include <stdlib.h>
20 #include <string.h>
21 #include <math.h>
22 #include <map>
23 #include <filesystem>
24 #include <ctype.h>
25 #include <sstream>
26 #include "base/zc_alleg.h"
27 #include "gamedata.h"
28 #include "zc_init.h"
29 #include "init.h"
30 #include "replay.h"
31 #include "cheats.h"
32 #include "render.h"
33 #include "base/zc_math.h"
34 #include "base/zapp.h"
35 #include "dialog/cheatkeys.h"
36
37 #ifdef ALLEGRO_DOS
38 #include <unistd.h>
39 #endif
40
41 #include "metadata/metadata.h"
42 #include "zelda.h"
43 #include "tiles.h"
44 #include "base/colors.h"
45 #include "pal.h"
46 #include "base/zsys.h"
47 #include "qst.h"
48 #include "zc_sys.h"
49 #include "play_midi.h"
50 #include "debug.h"
51 #include "jwin_a5.h"
52 #include "base/jwinfsel.h"
53 #include "base/gui.h"
54 #include "midi.h"
55 #include "subscr.h"
56 #include "maps.h"
57 #include "sprite.h"
58 #include "guys.h"
59 #include "hero.h"
60 #include "title.h"
61 #include "particles.h"
62 #include "zconsole.h"
63 #include "ffscript.h"
64 #include "dialog/info.h"
65 #include "dialog/alert.h"
66 #include "combos.h"
67 #include <fmt/format.h>
68
69 #ifdef __EMSCRIPTEN__
70 #include "base/emscripten_utils.h"
71 #endif
72
73 extern FFScript FFCore;
74 extern bool Playing;
75 int32_t sfx_voice[WAV_COUNT];
76 int32_t d_stringloader(int32_t msg,DIALOG *d,int32_t c);
77 int32_t d_midilist_proc(int32_t msg,DIALOG *d,int32_t c);
78
79 extern byte monochrome_console;
80
81 extern HeroClass Hero;
82 extern FFScript FFCore;
83 extern ZModule zcm;
84 extern zcmodule moduledata;
85 extern sprite_list guys, items, Ewpns, Lwpns, Sitems, chainlinks, decorations;
86 extern particle_list particles;
87 extern int32_t loadlast;
88 extern word passive_subscreen_doscript;
89 extern bool passive_subscreen_waitdraw;
90 extern char *sfx_string[WAV_COUNT];
91 byte use_dwm_flush;
92 byte use_save_indicator;
93 byte midi_patch_fix;
94 bool midi_paused=false;
95 int32_t paused_midi_pos = 0;
96 byte midi_suspended = 0;
97 byte callback_switchin = 0;
98 byte zc_192b163_warp_compatibility;
99 char modulepath[2048];
100 bool epilepsyFlashReduction;
101 signed char pause_in_background_menu_init = 0;
102 byte pause_in_background = 0;
103 bool is_sys_pal = false;
104 static bool load_control_called_this_frame;
105 extern PALETTE* hw_palette;
106 extern bool update_hw_pal;
107 extern const char* dmaplist(int32_t index, int32_t* list_size);
108 int32_t getnumber(const char *prompt,int32_t initialval);
109
110 extern bool kb_typing_mode; //script only, for disbaling key presses affecting Hero, etc.
111 extern int32_t cheat_modifier_keys[4]; //two options each, default either control and either shift
112 //extern byte refresh_select_screen;
113 //extern movingblock mblock2; //mblock[4]?
114 //extern int32_t db;
115
116 static const char *ZC_str = "Zelda Classic";
117 extern char save_file_name[1024];
118 #ifdef ALLEGRO_DOS
119 const char *qst_dir_name = "dos_qst_dir";
120 #elif defined(ALLEGRO_WINDOWS)
121 const char *qst_dir_name = "win_qst_dir";
122 static const char *qst_module_name = "current_module";
123 #elif defined(ALLEGRO_LINUX)
124 const char *qst_dir_name = "linux_qst_dir";
125 static const char *qst_module_name = "current_module";
126 #elif defined(__APPLE__)
127 const char *qst_dir_name = "osx_qst_dir";
128 static const char *qst_module_name = "current_module";
129 #endif
130 #ifdef ALLEGRO_LINUX
131 static const char *samplepath = "samplesoundset/patches.dat";
132 #endif
133 char qst_files_path[2048];
134
135 #ifdef _MSC_VER
136 #define getcwd _getcwd
137 #endif
138
139 bool rF11();
140 bool rI();
141 bool rQ();
142 bool zc_key_pressed();
143
144 #ifdef _WIN32
145
146 // This should only be necessary for MinGW, since it doesn't have a dwmapi.h. Add another #ifdef if you like.
147 extern "C"
148 {
149 typedef HRESULT(WINAPI *t_DwmFlush)();
150 typedef HRESULT(WINAPI *t_DwmIsCompositionEnabled)(BOOL *pfEnabled);
151 }
152
153 void do_DwmFlush()
154 {
155 static HMODULE shell = LoadLibrary("dwmapi.dll");
156
157 if(!shell)
158 return;
159
160 static t_DwmFlush flush=reinterpret_cast<t_DwmFlush>(GetProcAddress(shell, "DwmFlush"));
161 static t_DwmIsCompositionEnabled isEnabled=reinterpret_cast<t_DwmIsCompositionEnabled>(GetProcAddress(shell, "DwmIsCompositionEnabled"));
162
163 BOOL enabled;
164 isEnabled(&enabled);
165
166 if(isEnabled)
167 flush();
168 }
169
170 #endif // _WIN32
171
172 82451 bool flash_reduction_enabled(bool check_qr)
173 {
174
4/4
✓ Branch 0 taken 80230 times.
✓ Branch 1 taken 2221 times.
✓ Branch 2 taken 79774 times.
✓ Branch 3 taken 81995 times.
82451 return (check_qr && get_bit(quest_rules, qr_EPILEPSY)) || epilepsyFlashReduction || replay_is_debug();
175 }
176
177 // Dialogue largening
178 void large_dialog(DIALOG *d)
179 {
180 large_dialog(d, 1.5);
181 }
182
183 void large_dialog(DIALOG *d, float RESIZE_AMT)
184 {
185 if(!d[0].d1)
186 {
187 d[0].d1 = 1;
188 int32_t oldwidth = d[0].w;
189 int32_t oldheight = d[0].h;
190 int32_t oldx = d[0].x;
191 int32_t oldy = d[0].y;
192 d[0].x -= int32_t(d[0].w/RESIZE_AMT);
193 d[0].y -= int32_t(d[0].h/RESIZE_AMT);
194 d[0].w = int32_t(d[0].w*RESIZE_AMT);
195 d[0].h = int32_t(d[0].h*RESIZE_AMT);
196
197 for(int32_t i=1; d[i].proc !=NULL; i++)
198 {
199 // Place elements horizontally
200 double xpc = ((double)(d[i].x - oldx) / (double)oldwidth);
201 d[i].x = int32_t(d[0].x + (xpc*d[0].w));
202
203 if(d[i].proc != d_stringloader)
204 {
205 if(d[i].proc==d_bitmap_proc)
206 {
207 d[i].w *= 2;
208 }
209 else d[i].w = int32_t(d[i].w*RESIZE_AMT);
210 }
211
212 // Place elements vertically
213 double ypc = ((double)(d[i].y - oldy) / (double)oldheight);
214 d[i].y = int32_t(d[0].y + (ypc*d[0].h));
215
216 // Vertically resize elements
217 if(d[i].proc == jwin_edit_proc || d[i].proc == jwin_check_proc || d[i].proc == jwin_checkfont_proc)
218 {
219 d[i].h = int32_t((double)d[i].h*1.5);
220 }
221 else if(d[i].proc == jwin_droplist_proc)
222 {
223 d[i].y += int32_t((double)d[i].h*0.25);
224 d[i].h = int32_t((double)d[i].h*1.25);
225 }
226 else if(d[i].proc==d_bitmap_proc)
227 {
228 d[i].h *= 2;
229 }
230 else d[i].h = int32_t(d[i].h*RESIZE_AMT);
231
232 // Fix frames
233 if(d[i].proc == jwin_frame_proc)
234 {
235 d[i].x++;
236 d[i].y++;
237 d[i].w-=4;
238 d[i].h-=4;
239 }
240 }
241 }
242
243 for(int32_t i=1; d[i].proc!=NULL; i++)
244 {
245 if(d[i].proc==jwin_slider_proc)
246 continue;
247
248 // Bigger font
249 bool bigfontproc = (d[i].proc != d_midilist_proc && d[i].proc != jwin_droplist_proc && d[i].proc != jwin_abclist_proc && d[i].proc != jwin_list_proc);
250
251 if(!d[i].dp2 && bigfontproc)
252 {
253 d[i].dp2 = get_zc_font(font_lfont_l);
254 }
255 else if(!bigfontproc)
256 {
257 ((ListData *)d[i].dp)->font = &a4fonts[font_lfont_l];
258 }
259
260 // Make checkboxes work
261 if(d[i].proc == jwin_check_proc)
262 d[i].proc = jwin_checkfont_proc;
263 else if(d[i].proc == jwin_radio_proc)
264 d[i].proc = jwin_radiofont_proc;
265 }
266
267 jwin_center_dialog(d);
268 }
269
270
271 /**********************************/
272 /******** System functions ********/
273 /**********************************/
274
275 static char cfg_sect[] = "zeldadx"; //We need to rename this.
276 static char ctrl_sect[] = "Controls";
277 static char sfx_sect[] = "Volume";
278
279 int32_t d_dummy_proc(int32_t,DIALOG *,int32_t)
280 {
281 return D_O_K;
282 }
283
284 bool is_reserved_key(int c)
285 {
286 switch(c)
287 {
288 case KEY_ESC:
289 return true;
290 }
291 return false;
292 }
293 bool is_reserved_keycombo(int c, int modflag)
294 {
295 if(c==KEY_F4 && (modflag&KB_ALT_FLAG))
296 return true;
297 return false;
298 }
299 bool checkcheat(Cheat cheat)
300 {
301 if(cheatkeys[cheat][0] && zc_readkey(cheatkeys[cheat][0]))
302 return true; //Main key pressed
303 if(cheatkeys[cheat][1] && zc_readkey(cheatkeys[cheat][1]))
304 return true; //Alt key pressed
305 return false;
306 }
307 31 void load_default_cheatkeys()
308 {
309 31 memset(cheatkeys, 0, sizeof(cheatkeys));
310 31 cheatkeys[Cheat::Life][0] = KEY_H;
311 31 cheatkeys[Cheat::Life][1] = KEY_ASTERISK;
312 31 cheatkeys[Cheat::Magic][0] = KEY_M;
313 31 cheatkeys[Cheat::Magic][1] = KEY_SLASH_PAD;
314 31 cheatkeys[Cheat::Rupies][0] = KEY_R;
315 31 cheatkeys[Cheat::Bombs][0] = KEY_B;
316 31 cheatkeys[Cheat::Arrows][0] = KEY_A;
317 31 cheatkeys[Cheat::Clock][0] = KEY_I;
318 31 cheatkeys[Cheat::Walls][0] = KEY_F11;
319 31 cheatkeys[Cheat::Fast][0] = KEY_Q;
320 31 cheatkeys[Cheat::Light][0] = KEY_L;
321 31 cheatkeys[Cheat::IgnoreSideView][0] = KEY_V;
322 31 cheatkeys[Cheat::Kill][0] = KEY_K;
323 31 cheatkeys[Cheat::GoTo][0] = KEY_G;
324 31 cheatkeys[Cheat::TrigSecrets][0] = KEY_S;
325 31 cheatkeys[Cheat::ShowL0][0] = KEY_0;
326 31 cheatkeys[Cheat::ShowL1][0] = KEY_1;
327 31 cheatkeys[Cheat::ShowL2][0] = KEY_2;
328 31 cheatkeys[Cheat::ShowL3][0] = KEY_3;
329 31 cheatkeys[Cheat::ShowL4][0] = KEY_4;
330 31 cheatkeys[Cheat::ShowL5][0] = KEY_5;
331 31 cheatkeys[Cheat::ShowL6][0] = KEY_6;
332 31 cheatkeys[Cheat::ShowFFC][0] = KEY_7;
333 31 cheatkeys[Cheat::ShowSprites][0] = KEY_8;
334 31 cheatkeys[Cheat::ShowWalkability][0] = KEY_W;
335 31 cheatkeys[Cheat::ShowEffects][0] = KEY_E;
336 31 cheatkeys[Cheat::ShowOverhead][0] = KEY_O;
337 31 cheatkeys[Cheat::ShowPushblock][0] = KEY_P;
338 31 cheatkeys[Cheat::ShowHitbox][0] = KEY_C;
339 31 cheatkeys[Cheat::ShowFFCScripts][0] = KEY_F;
340 31 }
341 31 void load_game_configs()
342 {
343 31 strcpy(moduledata.module_name,zc_get_config("ZCMODULE",qst_module_name,"classic.zmod"));
344 31 joystick_index = zc_get_config(ctrl_sect,"joystick_index",0);
345 31 js_stick_1_x_stick = zc_get_config(ctrl_sect,"js_stick_1_x_stick",0);
346 31 js_stick_1_x_axis = zc_get_config(ctrl_sect,"js_stick_1_x_axis",0);
347 31 js_stick_1_x_offset = zc_get_config(ctrl_sect,"js_stick_1_x_offset",0) ? 128 : 0;
348 31 js_stick_1_y_stick = zc_get_config(ctrl_sect,"js_stick_1_y_stick",0);
349 31 js_stick_1_y_axis = zc_get_config(ctrl_sect,"js_stick_1_y_axis",1);
350 31 js_stick_1_y_offset = zc_get_config(ctrl_sect,"js_stick_1_y_offset",0) ? 128 : 0;
351 31 js_stick_2_x_stick = zc_get_config(ctrl_sect,"js_stick_2_x_stick",1);
352 31 js_stick_2_x_axis = zc_get_config(ctrl_sect,"js_stick_2_x_axis",0);
353 31 js_stick_2_x_offset = zc_get_config(ctrl_sect,"js_stick_2_x_offset",0) ? 128 : 0;
354 31 js_stick_2_y_stick = zc_get_config(ctrl_sect,"js_stick_2_y_stick",1);
355 31 js_stick_2_y_axis = zc_get_config(ctrl_sect,"js_stick_2_y_axis",1);
356 31 js_stick_2_y_offset = zc_get_config(ctrl_sect,"js_stick_2_y_offset",0) ? 128 : 0;
357 31 analog_movement = (zc_get_config(ctrl_sect,"analog_movement",1));
358
359 //cheat modifier keya
360 31 cheat_modifier_keys[0] = zc_get_config(ctrl_sect,"key_cheatmod_a1",KEY_ZC_LCONTROL);
361 31 cheat_modifier_keys[1] = zc_get_config(ctrl_sect,"key_cheatmod_a2",0);
362 31 cheat_modifier_keys[2] = zc_get_config(ctrl_sect,"key_cheatmod_b1",KEY_ZC_RCONTROL);
363 31 cheat_modifier_keys[3] = zc_get_config(ctrl_sect,"key_cheatmod_b2",0);
364
365 //cheat keys
366 31 load_default_cheatkeys();
367 char buf[256];
368
2/2
✓ Branch 0 taken 1085 times.
✓ Branch 1 taken 31 times.
1116 for(size_t q = 1; q < Cheat::Last; ++q)
369 {
370
1/2
✓ Branch 0 taken 1085 times.
✗ Branch 1 not taken.
1085 if(!bindable_cheat((Cheat)q)) continue;
371 1085 std::string cheatname = cheat_to_string((Cheat)q);
372
1/2
✓ Branch 0 taken 1085 times.
✗ Branch 1 not taken.
1085 util::lowerstr(cheatname);
373 1085 sprintf(buf, "key_cheat_%s_main", cheatname.c_str());
374
1/2
✓ Branch 0 taken 1085 times.
✗ Branch 1 not taken.
1085 cheatkeys[q][0] = zc_get_config(ctrl_sect,buf,cheatkeys[q][0]);
375 1085 sprintf(buf, "key_cheat_%s_alt", cheatname.c_str());
376
1/2
✓ Branch 0 taken 1085 times.
✗ Branch 1 not taken.
1085 cheatkeys[q][1] = zc_get_config(ctrl_sect,buf,cheatkeys[q][1]);
377 1085 }
378
379
1/2
✓ Branch 0 taken 31 times.
✗ Branch 1 not taken.
31 if((uint32_t)joystick_index >= MAX_JOYSTICKS)
380 joystick_index = 0;
381
382 31 Akey = zc_get_config(ctrl_sect,"key_a",KEY_Z);
383 31 Bkey = zc_get_config(ctrl_sect,"key_b",KEY_X);
384 31 Skey = zc_get_config(ctrl_sect,"key_s",KEY_ENTER);
385 31 Lkey = zc_get_config(ctrl_sect,"key_l",KEY_Q);
386 31 Rkey = zc_get_config(ctrl_sect,"key_r",KEY_W);
387 31 Pkey = zc_get_config(ctrl_sect,"key_p",KEY_SPACE);
388 31 Exkey1 = zc_get_config(ctrl_sect,"key_ex1",KEY_A);
389 31 Exkey2 = zc_get_config(ctrl_sect,"key_ex2",KEY_S);
390 31 Exkey3 = zc_get_config(ctrl_sect,"key_ex3",KEY_D);
391 31 Exkey4 = zc_get_config(ctrl_sect,"key_ex4",KEY_C);
392
393 31 DUkey = zc_get_config(ctrl_sect,"key_up", KEY_UP);
394 31 DDkey = zc_get_config(ctrl_sect,"key_down", KEY_DOWN);
395 31 DLkey = zc_get_config(ctrl_sect,"key_left", KEY_LEFT);
396 31 DRkey = zc_get_config(ctrl_sect,"key_right",KEY_RIGHT);
397
398 31 Abtn = zc_get_config(ctrl_sect,"btn_a",2);
399 31 Bbtn = zc_get_config(ctrl_sect,"btn_b",1);
400 31 Sbtn = zc_get_config(ctrl_sect,"btn_s",10);
401 31 Mbtn = zc_get_config(ctrl_sect,"btn_m",9);
402 31 Lbtn = zc_get_config(ctrl_sect,"btn_l",5);
403 31 Rbtn = zc_get_config(ctrl_sect,"btn_r",6);
404 31 Pbtn = zc_get_config(ctrl_sect,"btn_p",12);
405 31 Exbtn1 = zc_get_config(ctrl_sect,"btn_ex1",7);
406 31 Exbtn2 = zc_get_config(ctrl_sect,"btn_ex2",8);
407 31 Exbtn3 = zc_get_config(ctrl_sect,"btn_ex3",4);
408 31 Exbtn4 = zc_get_config(ctrl_sect,"btn_ex4",3);
409
410 31 DUbtn = zc_get_config(ctrl_sect,"btn_up",13);
411 31 DDbtn = zc_get_config(ctrl_sect,"btn_down",14);
412 31 DLbtn = zc_get_config(ctrl_sect,"btn_left",15);
413 31 DRbtn = zc_get_config(ctrl_sect,"btn_right",16);
414
415 31 epilepsyFlashReduction = zc_get_config(cfg_sect,"epilepsy_flash_reduction",0);
416
417 31 digi_volume = zc_get_config(sfx_sect,"digi",248);
418 31 midi_volume = zc_get_config(sfx_sect,"midi",255);
419 31 sfx_volume = zc_get_config(sfx_sect,"sfx",248);
420 31 emusic_volume = zc_get_config(sfx_sect,"emusic",248);
421 31 pan_style = zc_get_config(sfx_sect,"pan",1);
422 // 1 <= zcmusic_bufsz <= 128
423 31 zcmusic_bufsz = vbound(zc_get_config(sfx_sect,"zcmusic_bufsz",64),1,128);
424 31 volkeys = zc_get_config(sfx_sect,"volkeys",0)!=0;
425 31 zc_vsync = zc_get_config(cfg_sect,"vsync",0);
426 31 Throttlefps = zc_get_config(cfg_sect,"throttlefps",1)!=0;
427 31 TransLayers = zc_get_config(cfg_sect,"translayers",1)!=0;
428 31 SnapshotFormat = zc_get_config(cfg_sect,"snapshot_format",3);
429 31 NameEntryMode = zc_get_config(cfg_sect,"name_entry_mode",0);
430 #ifdef __EMSCRIPTEN__
431 if (em_is_mobile()) NameEntryMode = 2;
432 #endif
433 31 ShowFPS = zc_get_config(cfg_sect,"showfps",0)!=0;
434 31 NESquit = zc_get_config(cfg_sect,"fastquit",0)!=0;
435 31 ClickToFreeze = zc_get_config(cfg_sect,"clicktofreeze",1)!=0;
436 31 title_version = zc_get_config(cfg_sect,"title",2);
437 31 abc_patternmatch = zc_get_config(cfg_sect, "lister_pattern_matching", 1);
438 31 pause_in_background = zc_get_config(cfg_sect, "pause_in_background", 0);
439
440 //default - scale x2, 640 x 480
441 31 window_width = resx = zc_get_config(cfg_sect,"window_width",640);
442 31 window_height = resy = zc_get_config(cfg_sect,"window_height",480);
443 31 SaveDragResize = zc_get_config(cfg_sect,"save_drag_resize",0)!=0;
444 31 DragAspect = zc_get_config(cfg_sect,"drag_aspect",0)!=0;
445 31 SaveWinPos = zc_get_config(cfg_sect,"save_window_position",0)!=0;
446 31 scaleForceInteger = zc_get_config("zeldadx","scaling_force_integer",1)!=0;
447 31 stretchGame = zc_get_config("zeldadx","stretch_game_area",0)!=0;
448
449 31 loadlast = zc_get_config(cfg_sect,"load_last",0);
450
451 31 fullscreen = zc_get_config(cfg_sect,"fullscreen",0);
452
453 31 zc_color_depth = (byte) zc_get_config(cfg_sect,"color_depth",8);
454
455 31 forceExit = (byte) zc_get_config(cfg_sect,"force_exit",0);
456 31 info_opacity = zc_get_config("zc","debug_info_opacity",255);
457 #ifdef _WIN32
458 zasm_debugger = (byte) zc_get_config("CONSOLE","print_ZASM",0);
459 zscript_debugger = (byte) zc_get_config("CONSOLE","ZScript_Debugger",0);
460 //use_win7_keyboard_fix = (byte) zc_get_config(cfg_sect,"use_win7_key_fix",0);
461 use_win32_proc = (byte) zc_get_config(cfg_sect,"zc_win_proc_fix",0); //buggy
462
463 // This one's for Aero
464 use_dwm_flush = (byte) zc_get_config("zeldadx","use_dwm_flush",0);
465
466 // And this one fixes patches unloading on some MIDI setups
467 midi_patch_fix = (byte) zc_get_config("zeldadx","midi_patch_fix",1);
468 monochrome_console = (byte) zc_get_config("CONSOLE","monochrome_debuggers",0);
469 #else //UNIX
470 31 zasm_debugger = (byte) zc_get_config("CONSOLE","print_ZASM",0);
471 31 zscript_debugger = (byte) zc_get_config("CONSOLE","ZScript_Debugger",0);
472 31 monochrome_console = (byte) zc_get_config("CONSOLE","monochrome_debuggers",0);
473 #endif
474 31 clearConsoleOnLoad = zc_get_config("CONSOLE","clear_console_on_load",1)!=0;
475 31 clearConsoleOnReload = zc_get_config("CONSOLE","clear_console_on_reload",0)!=0;
476
477 31 char const* default_path = "";
478 31 strcpy(qstdir,zc_get_config(cfg_sect,qst_dir_name,default_path));
479
480
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 31 times.
31 if(strlen(qstdir)==0)
481 {
482 31 getcwd(qstdir,2048);
483 31 fix_filename_case(qstdir);
484 31 fix_filename_slashes(qstdir);
485 31 put_backslash(qstdir);
486 31 }
487 else
488 {
489 chop_path(qstdir);
490 }
491
492 31 strcpy(qstpath,qstdir); //qstpath is the local (for this run of ZC) quest path, qstdir is the universal quest dir.
493 31 ss_enable = zc_get_config(cfg_sect,"ss_enable",1) ? 1 : 0;
494 31 ss_after = vbound(zc_get_config(cfg_sect,"ss_after",14), 0, 14);
495 31 ss_speed = vbound(zc_get_config(cfg_sect,"ss_speed",2), 0, 6);
496 31 ss_density = vbound(zc_get_config(cfg_sect,"ss_density",3), 0, 6);
497 31 heart_beep = zc_get_config(cfg_sect,"heart_beep",1)!=0;
498 //gui_colorset = zc_get_config(cfg_sect,"gui_colorset",0);
499 31 sfxdat = zc_get_config(cfg_sect,"use_sfx_dat",1);
500 31 fullscreen = zc_get_config(cfg_sect,"fullscreen",0);
501 31 use_save_indicator = zc_get_config(cfg_sect,"save_indicator",0);
502 31 zc_192b163_warp_compatibility = zc_get_config(cfg_sect,"zc_192b163_warp_compatibility",0);
503 31 }
504
505 void save_control_configs(bool kb)
506 {
507 if(kb)
508 {
509 zc_set_config(ctrl_sect,"key_cheatmod_a1",cheat_modifier_keys[0]);
510 zc_set_config(ctrl_sect,"key_cheatmod_a2",cheat_modifier_keys[1]);
511 zc_set_config(ctrl_sect,"key_cheatmod_b1",cheat_modifier_keys[2]);
512 zc_set_config(ctrl_sect,"key_cheatmod_b2",cheat_modifier_keys[3]);
513
514 if (!replay_is_replaying())
515 {
516 zc_set_config(ctrl_sect,"key_a",Akey);
517 zc_set_config(ctrl_sect,"key_b",Bkey);
518 zc_set_config(ctrl_sect,"key_s",Skey);
519 zc_set_config(ctrl_sect,"key_l",Lkey);
520 zc_set_config(ctrl_sect,"key_r",Rkey);
521 zc_set_config(ctrl_sect,"key_p",Pkey);
522 zc_set_config(ctrl_sect,"key_ex1",Exkey1);
523 zc_set_config(ctrl_sect,"key_ex2",Exkey2);
524 zc_set_config(ctrl_sect,"key_ex3",Exkey3);
525 zc_set_config(ctrl_sect,"key_ex4",Exkey4);
526 zc_set_config(ctrl_sect,"key_up", DUkey);
527 zc_set_config(ctrl_sect,"key_down", DDkey);
528 zc_set_config(ctrl_sect,"key_left", DLkey);
529 zc_set_config(ctrl_sect,"key_right",DRkey);
530 }
531 }
532 else
533 {
534 zc_set_config(ctrl_sect,"joystick_index",joystick_index);
535 zc_set_config(ctrl_sect,"js_stick_1_x_stick",js_stick_1_x_stick);
536 zc_set_config(ctrl_sect,"js_stick_1_x_axis",js_stick_1_x_axis);
537 zc_set_config(ctrl_sect,"js_stick_1_x_offset",js_stick_1_x_offset ? 1 : 0);
538 zc_set_config(ctrl_sect,"js_stick_1_y_stick",js_stick_1_y_stick);
539 zc_set_config(ctrl_sect,"js_stick_1_y_axis",js_stick_1_y_axis);
540 zc_set_config(ctrl_sect,"js_stick_1_y_offset",js_stick_1_y_offset ? 1 : 0);
541 zc_set_config(ctrl_sect,"js_stick_2_x_stick",js_stick_2_x_stick);
542 zc_set_config(ctrl_sect,"js_stick_2_x_axis",js_stick_2_x_axis);
543 zc_set_config(ctrl_sect,"js_stick_2_x_offset",js_stick_2_x_offset ? 1 : 0);
544 zc_set_config(ctrl_sect,"js_stick_2_y_stick",js_stick_2_y_stick);
545 zc_set_config(ctrl_sect,"js_stick_2_y_axis",js_stick_2_y_axis);
546 zc_set_config(ctrl_sect,"js_stick_2_y_offset",js_stick_2_y_offset ? 1 : 0);
547 zc_set_config(ctrl_sect,"analog_movement",analog_movement);
548
549 zc_set_config(ctrl_sect,"btn_a",Abtn);
550 zc_set_config(ctrl_sect,"btn_b",Bbtn);
551 zc_set_config(ctrl_sect,"btn_s",Sbtn);
552 zc_set_config(ctrl_sect,"btn_m",Mbtn);
553 zc_set_config(ctrl_sect,"btn_l",Lbtn);
554 zc_set_config(ctrl_sect,"btn_r",Rbtn);
555 zc_set_config(ctrl_sect,"btn_p",Pbtn);
556 zc_set_config(ctrl_sect,"btn_ex1",Exbtn1);
557 zc_set_config(ctrl_sect,"btn_ex2",Exbtn2);
558 zc_set_config(ctrl_sect,"btn_ex3",Exbtn3);
559 zc_set_config(ctrl_sect,"btn_ex4",Exbtn4);
560
561 zc_set_config(ctrl_sect,"btn_up",DUbtn);
562 zc_set_config(ctrl_sect,"btn_down",DDbtn);
563 zc_set_config(ctrl_sect,"btn_left",DLbtn);
564 zc_set_config(ctrl_sect,"btn_right",DRbtn);
565 }
566 }
567
568 void save_cheatkeys()
569 {
570 char buf[256];
571 for(size_t q = 1; q < Cheat::Last; ++q)
572 {
573 if(!bindable_cheat((Cheat)q)) continue;
574 std::string cheatname = cheat_to_string((Cheat)q);
575 util::lowerstr(cheatname);
576 sprintf(buf, "key_cheat_%s_main", cheatname.c_str());
577 zc_set_config(ctrl_sect,buf,cheatkeys[q][0]);
578 sprintf(buf, "key_cheat_%s_alt", cheatname.c_str());
579 if(cheatkeys[q][1])
580 zc_set_config(ctrl_sect,buf,cheatkeys[q][1]);
581 else zc_set_config(ctrl_sect,buf,(char*)nullptr);
582 }
583 }
584
585 void save_game_configs()
586 {
587 packfile_password("");
588
589 zc_set_config("ZCMODULE",qst_module_name,moduledata.module_name);
590
591 if (all_get_display() && !all_get_fullscreen_flag()&& SaveWinPos)
592 {
593 int o_window_x, o_window_y;
594 al_get_window_position(all_get_display(), &o_window_x, &o_window_y);
595 zc_set_config(cfg_sect,"window_x",o_window_x);
596 zc_set_config(cfg_sect,"window_y",o_window_y);
597 }
598
599 if (all_get_display() && !all_get_fullscreen_flag() && SaveDragResize)
600 {
601 double monitor_scale = zc_get_monitor_scale();
602 window_width = al_get_display_width(all_get_display()) / monitor_scale;
603 window_height = al_get_display_height(all_get_display()) / monitor_scale;
604 zc_set_config(cfg_sect,"window_width",window_width);
605 zc_set_config(cfg_sect,"window_height",window_height);
606 }
607
608 zc_set_config(cfg_sect,"load_last",loadlast);
609 chop_path(qstdir);
610 zc_set_config(cfg_sect,qst_dir_name,qstdir);
611 zc_set_config("SAVEFILE","save_filename",save_file_name);
612 zc_set_config(cfg_sect,"use_sfx_dat",sfxdat);
613
614 flush_config_file();
615 #ifdef __EMSCRIPTEN__
616 em_sync_fs();
617 #endif
618 }
619
620 //----------------------------------------------------------------
621
622 // Timers
623
624 28124 void fps_callback()
625 {
626 28124 lastfps=framecnt;
627 28124 dword tempsecs = fps_secs;
628 28124 ++tempsecs;
629 //avgfps=((long double)avgfps*fps_secs+lastfps)/(++fps_secs); // DJGPP doesn't like this
630 28124 avgfps=((long double)avgfps*fps_secs+lastfps)/(tempsecs);
631 28124 ++fps_secs;
632 28124 framecnt=0;
633 28124 }
634
635 END_OF_FUNCTION(fps_callback)
636
637 31 int32_t Z_init_timers()
638 {
639 static bool didit = false;
640 const static char *err_str = "Couldn't allocate timer";
641 31 err_str = err_str; //Unused variable warning
642
643
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 31 times.
31 if(didit)
644 return 1;
645
646 31 didit = true;
647
648 LOCK_VARIABLE(lastfps);
649 LOCK_VARIABLE(framecnt);
650 LOCK_FUNCTION(fps_callback);
651
652
1/2
✓ Branch 0 taken 31 times.
✗ Branch 1 not taken.
31 if(install_int_ex(fps_callback,SECS_TO_TIMER(1)))
653 return 0;
654
655 31 return 1;
656 31 }
657
658 void Z_remove_timers()
659 {
660 remove_int(fps_callback);
661 }
662
663 //----------------------------------------------------------------
664
665 void go()
666 {
667 blit(screen,tmp_scr,scrx,scry,0,0,screen->w,screen->h);
668 }
669
670 void comeback()
671 {
672 blit(tmp_scr,screen,0,0,scrx,scry,screen->w,screen->h);
673 }
674
675 void dump_pal(BITMAP *dest)
676 {
677 for(int32_t i=0; i<256; i++)
678 rectfill(dest,(i&63)<<2,(i&0xFC0)>>4,((i&63)<<2)+3,((i&0xFC0)>>4)+3,i);
679 }
680
681 //----------------------------------------------------------------
682
683 //Handles converting the mouse sprite from the .dat file
684 31 void load_mouse()
685 {
686 31 system_pal();
687 31 MouseSprite::set(-1);
688 31 int32_t sz = vbound(int32_t(16*(zc_get_config("zeldadx","cursor_scale_large",1.5))),16,80);
689
2/2
✓ Branch 0 taken 124 times.
✓ Branch 1 taken 31 times.
155 for(int32_t j = 0; j < 4; ++j)
690 {
691 124 BITMAP* tmpbmp = create_bitmap_ex(8,16,16);
692 124 BITMAP* subbmp = create_bitmap_ex(8,16,16);
693
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 if(zcmouse[j])
694 destroy_bitmap(zcmouse[j]);
695 124 zcmouse[j] = create_bitmap_ex(8,sz,sz);
696 124 clear_bitmap(zcmouse[j]);
697 124 clear_bitmap(tmpbmp);
698 124 clear_bitmap(subbmp);
699 124 blit((BITMAP*)datafile[BMP_MOUSE].dat,tmpbmp,1,j*17+1,0,0,16,16);
700
2/2
✓ Branch 0 taken 1984 times.
✓ Branch 1 taken 124 times.
2108 for(int32_t x = 0; x < 16; ++x)
701 {
702
2/2
✓ Branch 0 taken 31744 times.
✓ Branch 1 taken 1984 times.
33728 for(int32_t y = 0; y < 16; ++y)
703 {
704 31744 int32_t color = getpixel(tmpbmp, x, y);
705
5/5
✓ Branch 0 taken 29202 times.
✓ Branch 1 taken 589 times.
✓ Branch 2 taken 682 times.
✓ Branch 3 taken 713 times.
✓ Branch 4 taken 558 times.
31744 switch(color)
706 {
707 case dvc(1):
708 589 color = jwin_pal[jcCURSORMISC];
709 589 break;
710 case dvc(2):
711 682 color = jwin_pal[jcCURSOROUTLINE];
712 682 break;
713 case dvc(3):
714 713 color = jwin_pal[jcCURSORLIGHT];
715 713 break;
716 case dvc(5):
717 558 color = jwin_pal[jcCURSORDARK];
718 558 break;
719 }
720 31744 putpixel(subbmp, x, y, color);
721 31744 }
722 1984 }
723
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 if(sz!=16)
724 124 stretch_blit(subbmp, zcmouse[j], 0, 0, 16, 16, 0, 0, sz, sz);
725 else
726 blit(subbmp, zcmouse[j], 0, 0, 0, 0, 16, 16);
727 124 destroy_bitmap(tmpbmp);
728 124 destroy_bitmap(subbmp);
729 124 }
730 31 zc_set_palette(*hw_palette);
731
732 31 MouseSprite::assign(0, zcmouse[0]);
733 31 MouseSprite::set(0);
734
735 31 game_pal();
736 31 }
737
738 // sets the video mode and initializes the palette and mouse sprite
739 31 bool game_vid_mode(int32_t mode,int32_t wait)
740 {
741
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 31 times.
31 if(set_gfx_mode(mode,resx,resy,0,0)!=0)
742 {
743 return false;
744 }
745
746 31 scrx = (resx-320)>>1;
747 31 scry = (resy-240)>>1;
748
2/2
✓ Branch 0 taken 124 times.
✓ Branch 1 taken 31 times.
155 for(int32_t q = 0; q < 4; ++q)
749 124 zcmouse[q] = NULL;
750 31 load_mouse();
751
752
2/2
✓ Branch 0 taken 496 times.
✓ Branch 1 taken 31 times.
527 for(int32_t i=240; i<256; i++)
753 496 RAMpal[i]=((RGB*)datafile[PAL_GUI].dat)[i];
754
755 31 zc_set_palette(RAMpal);
756 31 clear_to_color(screen,BLACK);
757
758 31 rest(wait);
759 31 return true;
760 31 }
761
762 6 void null_quest()
763 {
764 char qstdat_string[2048];
765 6 strcpy(qstdat_string,moduledata.datafiles[qst_dat]);
766 6 strcat(qstdat_string,"#NESQST_NEW_QST");
767
768 #ifdef __EMSCRIPTEN__
769 // The quest template data file is not included because it's really big and isn't really needed
770 // for the player, except to initialize some graphics. Those same graphics exist in this quest file,
771 // which is much smaller.
772 strcpy(qstdat_string, "modules/classic/title_gfx.dat");
773 #endif
774
775 6 byte skip_flags[4] = { 0 };
776
777 6 loadquest(qstdat_string,&QHeader,&QMisc,tunes+ZC_MIDI_COUNT,false,true,true,true,skip_flags,0,false);
778 6 }
779
780 6 void init_NES_mode()
781 {
782 /*
783 // qst.dat may not load correctly without this...
784 QHeader.templatepath[0]='\0';
785
786 if(!init_colordata(true, &QHeader, &QMisc))
787 {
788 return;
789 }
790
791 loadfullpal();
792 init_tiles(false, &QHeader);
793 */
794 6 null_quest();
795 6 }
796
797 //----------------------------------------------------------------
798
799 qword trianglelines[16]=
800 {
801 0x0000000000000000ULL,
802 0xFD00000000000000ULL,
803 0xFDFD000000000000ULL,
804 0xFDFDFD0000000000ULL,
805 0xFDFDFDFD00000000ULL,
806 0xFDFDFDFDFD000000ULL,
807 0xFDFDFDFDFDFD0000ULL,
808 0xFDFDFDFDFDFDFD00ULL,
809 0xFDFDFDFDFDFDFDFDULL,
810 0x00FDFDFDFDFDFDFDULL,
811 0x0000FDFDFDFDFDFDULL,
812 0x000000FDFDFDFDFDULL,
813 0x00000000FDFDFDFDULL,
814 0x0000000000FDFDFDULL,
815 0x000000000000FDFDULL,
816 0x00000000000000FDULL,
817 };
818
819 word screen_triangles[28][32];
820 /*
821 qword triangles[4][16]= //[direction][value]
822 {
823 {
824 0x00000000, 0x10000000, 0x21000000, 0x32100000, 0x43210000, 0x54321000, 0x65432100, 0x76543210, 0x87654321, 0x88765432, 0x88876543, 0x88887654, 0x88888765, 0x88888876, 0x88888887, 0x88888888
825 },
826 {
827 0x00000000, 0xF0000000, 0xEF000000, 0xFDF00000, 0xCFDF0000, 0xBCFDF000, 0xABCFDF00, 0x9ABCFDF0, 0x89ABCFDF, 0x889ABCFD, 0x8889ABCD, 0x88889ABC, 0x888889AB, 0x8888889A, 0x88888889, 0x88888888
828 },
829 {
830 0x00000000, 0x00000001, 0x00000012, 0x00000123, 0x00001234, 0x00012345, 0x00123456, 0x01234567, 0x12345678, 0x23456788, 0x34567888, 0x45678888, 0x56788888, 0x67888888, 0x78888888, 0x88888888
831 },
832 {
833 0x00000000, 0x0000000F, 0x000000FE, 0x00000FED, 0x0000FEDC, 0x000FEDCB, 0x00FEDCBA, 0x0FEDCBA9, 0xFEDCBA98, 0xEDCBA988, 0xDCBA9888, 0xCBA98888, 0xBA988888, 0xA9888888, 0x98888888, 0x88888888
834 }
835 };
836 */
837
838
839 /*
840 byte triangles[4][16][8]= //[direction][value][line]
841 {
842 {
843 {
844 0, 0, 0, 0, 0, 0, 0, 0
845 },
846 {
847 1, 0, 0, 0, 0, 0, 0, 0
848 },
849 {
850 2, 1, 0, 0, 0, 0, 0, 0
851 },
852 {
853 3, 2, 1, 0, 0, 0, 0, 0
854 },
855 {
856 4, 3, 2, 1, 0, 0, 0, 0
857 },
858 {
859 5, 4, 3, 2, 1, 0, 0, 0
860 },
861 {
862 6, 5, 4, 3, 2, 1, 0, 0
863 },
864 {
865 7, 6, 5, 4, 3, 2, 1, 0
866 },
867 {
868 8, 7, 6, 5, 4, 3, 2, 1
869 },
870 {
871 8, 8, 7, 6, 5, 4, 3, 2
872 },
873 {
874 8, 8, 8, 7, 6, 5, 4, 3
875 },
876 {
877 8, 8, 8, 8, 7, 6, 5, 4
878 },
879 {
880 8, 8, 8, 8, 8, 7, 6, 5
881 },
882 {
883 8, 8, 8, 8, 8, 8, 7, 6
884 },
885 {
886 8, 8, 8, 8, 8, 8, 8, 7
887 },
888 {
889 8, 8, 8, 8, 8, 8, 8, 8
890 }
891 },
892 {
893 {
894 0, 0, 0, 0, 0, 0, 0, 0
895 },
896 {
897 15, 0, 0, 0, 0, 0, 0, 0
898 },
899 {
900 14, 15, 0, 0, 0, 0, 0, 0
901 },
902 {
903 13, 14, 15, 0, 0, 0, 0, 0
904 },
905 {
906 12, 13, 14, 15, 0, 0, 0, 0
907 },
908 {
909 11, 12, 13, 14, 15, 0, 0, 0
910 },
911 {
912 10, 11, 12, 13, 14, 15, 0, 0
913 },
914 {
915 9, 10, 11, 12, 13, 14, 15, 0
916 },
917 {
918 8, 9, 10, 11, 12, 13, 14, 15
919 },
920 {
921 8, 8, 9, 10, 11, 12, 13, 14
922 },
923 {
924 8, 8, 8, 9, 10, 11, 12, 13
925 },
926 {
927 8, 8, 8, 8, 9, 10, 11, 12
928 },
929 {
930 8, 8, 8, 8, 8, 9, 10, 11
931 },
932 {
933 8, 8, 8, 8, 8, 8, 9, 10
934 },
935 {
936 8, 8, 8, 8, 8, 8, 8, 9
937 },
938 {
939 8, 8, 8, 8, 8, 8, 8, 8
940 }
941 },
942 {
943 {
944 0, 0, 0, 0, 0, 0, 0, 0
945 },
946 {
947 0, 0, 0, 0, 0, 0, 0, 1
948 },
949 {
950 0, 0, 0, 0, 0, 0, 1, 2
951 },
952 {
953 0, 0, 0, 0, 0, 1, 2, 3
954 },
955 {
956 0, 0, 0, 0, 1, 2, 3, 4
957 },
958 {
959 0, 0, 0, 1, 2, 3, 4, 5
960 },
961 {
962 0, 0, 1, 2, 3, 4, 5, 6
963 },
964 {
965 0, 1, 2, 3, 4, 5, 6, 7
966 },
967 {
968 1, 2, 3, 4, 5, 6, 7, 8
969 },
970 {
971 2, 3, 4, 5, 6, 7, 8, 8
972 },
973 {
974 3, 4, 5, 6, 7, 8, 8, 8
975 },
976 {
977 4, 5, 6, 7, 8, 8, 8, 8
978 },
979 {
980 5, 6, 7, 8, 8, 8, 8, 8
981 },
982 {
983 6, 7, 8, 8, 8, 8, 8, 8
984 },
985 {
986 7, 8, 8, 8, 8, 8, 8, 8
987 },
988 {
989 8, 8, 8, 8, 8, 8, 8, 8
990 }
991 },
992 {
993 {
994 0, 0, 0, 0, 0, 0, 0, 0
995 },
996 {
997 0, 0, 0, 0, 0, 0, 0, 15
998 },
999 {
1000 0, 0, 0, 0, 0, 0, 15, 14
1001 },
1002 {
1003 0, 0, 0, 0, 0, 15, 14, 13
1004 },
1005 {
1006 0, 0, 0, 0, 15, 14, 13, 12
1007 },
1008 {
1009 0, 0, 0, 15, 14, 13, 12, 11
1010 },
1011 {
1012 0, 0, 15, 14, 13, 12, 11, 10
1013 },
1014 {
1015 0, 15, 14, 13, 12, 11, 10, 9
1016 },
1017 {
1018 15, 14, 13, 12, 11, 10, 9, 8
1019 },
1020 {
1021 14, 13, 12, 11, 10, 9, 8, 8
1022 },
1023 {
1024 13, 12, 11, 10, 9, 8, 8, 8
1025 },
1026 {
1027 12, 11, 10, 9, 8, 8, 8, 8
1028 },
1029 {
1030 11, 10, 9, 8, 8, 8, 8, 8
1031 },
1032 {
1033 10, 9, 8, 8, 8, 8, 8, 8
1034 },
1035 {
1036 9, 8, 8, 8, 8, 8, 8, 8
1037 },
1038 {
1039 8, 8, 8, 8, 8, 8, 8, 8
1040 }
1041 }
1042 };
1043 */
1044
1045
1046
1047 /*
1048 for (int32_t blockrow=0; blockrow<30; ++i)
1049 {
1050 for (int32_t linerow=0; linerow<8; ++i)
1051 {
1052 qword *triangleline=(qword*)(tmp_scr->line[(blockrow*8+linerow)]);
1053 for (int32_t blockcolumn=0; blockcolumn<40; ++i)
1054 {
1055 triangleline=triangles[0][screen_triangles[blockrow][blockcolumn]][linerow];
1056 ++triangleline;
1057 }
1058 }
1059 }
1060 */
1061
1062 // the ULL suffixes are to prevent this warning:
1063 // warning: integer constant is too large for "int32_t" type
1064
1065 qword triangles[4][16][8]= //[direction][value][line]
1066 {
1067 {
1068 {
1069 0x0000000000000000ULL,
1070 0x0000000000000000ULL,
1071 0x0000000000000000ULL,
1072 0x0000000000000000ULL,
1073 0x0000000000000000ULL,
1074 0x0000000000000000ULL,
1075 0x0000000000000000ULL,
1076 0x0000000000000000ULL
1077 },
1078 {
1079 0xFD00000000000000ULL,
1080 0x0000000000000000ULL,
1081 0x0000000000000000ULL,
1082 0x0000000000000000ULL,
1083 0x0000000000000000ULL,
1084 0x0000000000000000ULL,
1085 0x0000000000000000ULL,
1086 0x0000000000000000ULL
1087 },
1088 {
1089 0xFDFD000000000000ULL,
1090 0xFD00000000000000ULL,
1091 0x0000000000000000ULL,
1092 0x0000000000000000ULL,
1093 0x0000000000000000ULL,
1094 0x0000000000000000ULL,
1095 0x0000000000000000ULL,
1096 0x0000000000000000ULL
1097 },
1098 {
1099 0xFDFDFD0000000000ULL,
1100 0xFDFD000000000000ULL,
1101 0xFD00000000000000ULL,
1102 0x0000000000000000ULL,
1103 0x0000000000000000ULL,
1104 0x0000000000000000ULL,
1105 0x0000000000000000ULL,
1106 0x0000000000000000ULL
1107 },
1108 {
1109 0xFDFDFDFD00000000ULL,
1110 0xFDFDFD0000000000ULL,
1111 0xFDFD000000000000ULL,
1112 0xFD00000000000000ULL,
1113 0x0000000000000000ULL,
1114 0x0000000000000000ULL,
1115 0x0000000000000000ULL,
1116 0x0000000000000000ULL
1117 },
1118 {
1119 0xFDFDFDFDFD000000ULL,
1120 0xFDFDFDFD00000000ULL,
1121 0xFDFDFD0000000000ULL,
1122 0xFDFD000000000000ULL,
1123 0xFD00000000000000ULL,
1124 0x0000000000000000ULL,
1125 0x0000000000000000ULL,
1126 0x0000000000000000ULL
1127 },
1128 {
1129 0xFDFDFDFDFDFD0000ULL,
1130 0xFDFDFDFDFD000000ULL,
1131 0xFDFDFDFD00000000ULL,
1132 0xFDFDFD0000000000ULL,
1133 0xFDFD000000000000ULL,
1134 0xFD00000000000000ULL,
1135 0x0000000000000000ULL,
1136 0x0000000000000000ULL
1137 },
1138 {
1139 0xFDFDFDFDFDFDFD00ULL,
1140 0xFDFDFDFDFDFD0000ULL,
1141 0xFDFDFDFDFD000000ULL,
1142 0xFDFDFDFD00000000ULL,
1143 0xFDFDFD0000000000ULL,
1144 0xFDFD000000000000ULL,
1145 0xFD00000000000000ULL,
1146 0x0000000000000000ULL
1147 },
1148 {
1149 0xFDFDFDFDFDFDFDFDULL,
1150 0xFDFDFDFDFDFDFD00ULL,
1151 0xFDFDFDFDFDFD0000ULL,
1152 0xFDFDFDFDFD000000ULL,
1153 0xFDFDFDFD00000000ULL,
1154 0xFDFDFD0000000000ULL,
1155 0xFDFD000000000000ULL,
1156 0xFD00000000000000ULL
1157 },
1158 {
1159 0xFDFDFDFDFDFDFDFDULL,
1160 0xFDFDFDFDFDFDFDFDULL,
1161 0xFDFDFDFDFDFDFD00ULL,
1162 0xFDFDFDFDFDFD0000ULL,
1163 0xFDFDFDFDFD000000ULL,
1164 0xFDFDFDFD00000000ULL,
1165 0xFDFDFD0000000000ULL,
1166 0xFDFD000000000000ULL
1167 },
1168 {
1169 0xFDFDFDFDFDFDFDFDULL,
1170 0xFDFDFDFDFDFDFDFDULL,
1171 0xFDFDFDFDFDFDFDFDULL,
1172 0xFDFDFDFDFDFDFD00ULL,
1173 0xFDFDFDFDFDFD0000ULL,
1174 0xFDFDFDFDFD000000ULL,
1175 0xFDFDFDFD00000000ULL,
1176 0xFDFDFD0000000000ULL
1177 },
1178 {
1179 0xFDFDFDFDFDFDFDFDULL,
1180 0xFDFDFDFDFDFDFDFDULL,
1181 0xFDFDFDFDFDFDFDFDULL,
1182 0xFDFDFDFDFDFDFDFDULL,
1183 0xFDFDFDFDFDFDFD00ULL,
1184 0xFDFDFDFDFDFD0000ULL,
1185 0xFDFDFDFDFD000000ULL,
1186 0xFDFDFDFD00000000ULL
1187 },
1188 {
1189 0xFDFDFDFDFDFDFDFDULL,
1190 0xFDFDFDFDFDFDFDFDULL,
1191 0xFDFDFDFDFDFDFDFDULL,
1192 0xFDFDFDFDFDFDFDFDULL,
1193 0xFDFDFDFDFDFDFDFDULL,
1194 0xFDFDFDFDFDFDFD00ULL,
1195 0xFDFDFDFDFDFD0000ULL,
1196 0xFDFDFDFDFD000000ULL
1197 },
1198 {
1199 0xFDFDFDFDFDFDFDFDULL,
1200 0xFDFDFDFDFDFDFDFDULL,
1201 0xFDFDFDFDFDFDFDFDULL,
1202 0xFDFDFDFDFDFDFDFDULL,
1203 0xFDFDFDFDFDFDFDFDULL,
1204 0xFDFDFDFDFDFDFDFDULL,
1205 0xFDFDFDFDFDFDFD00ULL,
1206 0xFDFDFDFDFDFD0000ULL
1207 },
1208 {
1209 0xFDFDFDFDFDFDFDFDULL,
1210 0xFDFDFDFDFDFDFDFDULL,
1211 0xFDFDFDFDFDFDFDFDULL,
1212 0xFDFDFDFDFDFDFDFDULL,
1213 0xFDFDFDFDFDFDFDFDULL,
1214 0xFDFDFDFDFDFDFDFDULL,
1215 0xFDFDFDFDFDFDFDFDULL,
1216 0xFDFDFDFDFDFDFD00ULL
1217 },
1218 {
1219 0xFDFDFDFDFDFDFDFDULL,
1220 0xFDFDFDFDFDFDFDFDULL,
1221 0xFDFDFDFDFDFDFDFDULL,
1222 0xFDFDFDFDFDFDFDFDULL,
1223 0xFDFDFDFDFDFDFDFDULL,
1224 0xFDFDFDFDFDFDFDFDULL,
1225 0xFDFDFDFDFDFDFDFDULL,
1226 0xFDFDFDFDFDFDFDFDULL
1227 }
1228 },
1229 {
1230 {
1231 0x0000000000000000ULL,
1232 0x0000000000000000ULL,
1233 0x0000000000000000ULL,
1234 0x0000000000000000ULL,
1235 0x0000000000000000ULL,
1236 0x0000000000000000ULL,
1237 0x0000000000000000ULL,
1238 0x0000000000000000ULL
1239 },
1240 {
1241 0x00000000000000FDULL,
1242 0x0000000000000000ULL,
1243 0x0000000000000000ULL,
1244 0x0000000000000000ULL,
1245 0x0000000000000000ULL,
1246 0x0000000000000000ULL,
1247 0x0000000000000000ULL,
1248 0x0000000000000000ULL
1249 },
1250 {
1251 0x000000000000FDFDULL,
1252 0x00000000000000FDULL,
1253 0x0000000000000000ULL,
1254 0x0000000000000000ULL,
1255 0x0000000000000000ULL,
1256 0x0000000000000000ULL,
1257 0x0000000000000000ULL,
1258 0x0000000000000000ULL
1259 },
1260 {
1261 0x0000000000FDFDFDULL,
1262 0x000000000000FDFDULL,
1263 0x00000000000000FDULL,
1264 0x0000000000000000ULL,
1265 0x0000000000000000ULL,
1266 0x0000000000000000ULL,
1267 0x0000000000000000ULL,
1268 0x0000000000000000ULL
1269 },
1270 {
1271 0x00000000FDFDFDFDULL,
1272 0x0000000000FDFDFDULL,
1273 0x000000000000FDFDULL,
1274 0x00000000000000FDULL,
1275 0x0000000000000000ULL,
1276 0x0000000000000000ULL,
1277 0x0000000000000000ULL,
1278 0x0000000000000000ULL
1279 },
1280 {
1281 0x000000FDFDFDFDFDULL,
1282 0x00000000FDFDFDFDULL,
1283 0x0000000000FDFDFDULL,
1284 0x000000000000FDFDULL,
1285 0x00000000000000FDULL,
1286 0x0000000000000000ULL,
1287 0x0000000000000000ULL,
1288 0x0000000000000000ULL
1289 },
1290 {
1291 0x0000FDFDFDFDFDFDULL,
1292 0x000000FDFDFDFDFDULL,
1293 0x00000000FDFDFDFDULL,
1294 0x0000000000FDFDFDULL,
1295 0x000000000000FDFDULL,
1296 0x00000000000000FDULL,
1297 0x0000000000000000ULL,
1298 0x0000000000000000ULL
1299 },
1300 {
1301 0x00FDFDFDFDFDFDFDULL,
1302 0x0000FDFDFDFDFDFDULL,
1303 0x000000FDFDFDFDFDULL,
1304 0x00000000FDFDFDFDULL,
1305 0x0000000000FDFDFDULL,
1306 0x000000000000FDFDULL,
1307 0x00000000000000FDULL,
1308 0x0000000000000000ULL
1309 },
1310 {
1311 0xFDFDFDFDFDFDFDFDULL,
1312 0x00FDFDFDFDFDFDFDULL,
1313 0x0000FDFDFDFDFDFDULL,
1314 0x000000FDFDFDFDFDULL,
1315 0x00000000FDFDFDFDULL,
1316 0x0000000000FDFDFDULL,
1317 0x000000000000FDFDULL,
1318 0x00000000000000FDULL
1319 },
1320 {
1321 0xFDFDFDFDFDFDFDFDULL,
1322 0xFDFDFDFDFDFDFDFDULL,
1323 0x00FDFDFDFDFDFDFDULL,
1324 0x0000FDFDFDFDFDFDULL,
1325 0x000000FDFDFDFDFDULL,
1326 0x00000000FDFDFDFDULL,
1327 0x0000000000FDFDFDULL,
1328 0x000000000000FDFDULL
1329 },
1330 {
1331 0xFDFDFDFDFDFDFDFDULL,
1332 0xFDFDFDFDFDFDFDFDULL,
1333 0xFDFDFDFDFDFDFDFDULL,
1334 0x00FDFDFDFDFDFDFDULL,
1335 0x0000FDFDFDFDFDFDULL,
1336 0x000000FDFDFDFDFDULL,
1337 0x00000000FDFDFDFDULL,
1338 0x0000000000FDFDFDULL
1339 },
1340 {
1341 0xFDFDFDFDFDFDFDFDULL,
1342 0xFDFDFDFDFDFDFDFDULL,
1343 0xFDFDFDFDFDFDFDFDULL,
1344 0xFDFDFDFDFDFDFDFDULL,
1345 0x00FDFDFDFDFDFDFDULL,
1346 0x0000FDFDFDFDFDFDULL,
1347 0x000000FDFDFDFDFDULL,
1348 0x00000000FDFDFDFDULL
1349 },
1350 {
1351 0xFDFDFDFDFDFDFDFDULL,
1352 0xFDFDFDFDFDFDFDFDULL,
1353 0xFDFDFDFDFDFDFDFDULL,
1354 0xFDFDFDFDFDFDFDFDULL,
1355 0xFDFDFDFDFDFDFDFDULL,
1356 0x00FDFDFDFDFDFDFDULL,
1357 0x0000FDFDFDFDFDFDULL,
1358 0x000000FDFDFDFDFDULL
1359 },
1360 {
1361 0xFDFDFDFDFDFDFDFDULL,
1362 0xFDFDFDFDFDFDFDFDULL,
1363 0xFDFDFDFDFDFDFDFDULL,
1364 0xFDFDFDFDFDFDFDFDULL,
1365 0xFDFDFDFDFDFDFDFDULL,
1366 0xFDFDFDFDFDFDFDFDULL,
1367 0x00FDFDFDFDFDFDFDULL,
1368 0x0000FDFDFDFDFDFDULL
1369 },
1370 {
1371 0xFDFDFDFDFDFDFDFDULL,
1372 0xFDFDFDFDFDFDFDFDULL,
1373 0xFDFDFDFDFDFDFDFDULL,
1374 0xFDFDFDFDFDFDFDFDULL,
1375 0xFDFDFDFDFDFDFDFDULL,
1376 0xFDFDFDFDFDFDFDFDULL,
1377 0xFDFDFDFDFDFDFDFDULL,
1378 0x00FDFDFDFDFDFDFDULL
1379 },
1380 {
1381 0xFDFDFDFDFDFDFDFDULL,
1382 0xFDFDFDFDFDFDFDFDULL,
1383 0xFDFDFDFDFDFDFDFDULL,
1384 0xFDFDFDFDFDFDFDFDULL,
1385 0xFDFDFDFDFDFDFDFDULL,
1386 0xFDFDFDFDFDFDFDFDULL,
1387 0xFDFDFDFDFDFDFDFDULL,
1388 0xFDFDFDFDFDFDFDFDULL
1389 }
1390 },
1391 {
1392 {
1393 0x0000000000000000ULL,
1394 0x0000000000000000ULL,
1395 0x0000000000000000ULL,
1396 0x0000000000000000ULL,
1397 0x0000000000000000ULL,
1398 0x0000000000000000ULL,
1399 0x0000000000000000ULL,
1400 0x0000000000000000ULL
1401 },
1402 {
1403 0x0000000000000000ULL,
1404 0x0000000000000000ULL,
1405 0x0000000000000000ULL,
1406 0x0000000000000000ULL,
1407 0x0000000000000000ULL,
1408 0x0000000000000000ULL,
1409 0x0000000000000000ULL,
1410 0xFD00000000000000ULL
1411 },
1412 {
1413 0x0000000000000000ULL,
1414 0x0000000000000000ULL,
1415 0x0000000000000000ULL,
1416 0x0000000000000000ULL,
1417 0x0000000000000000ULL,
1418 0x0000000000000000ULL,
1419 0xFD00000000000000ULL,
1420 0xFDFD000000000000ULL
1421 },
1422 {
1423 0x0000000000000000ULL,
1424 0x0000000000000000ULL,
1425 0x0000000000000000ULL,
1426 0x0000000000000000ULL,
1427 0x0000000000000000ULL,
1428 0xFD00000000000000ULL,
1429 0xFDFD000000000000ULL,
1430 0xFDFDFD0000000000ULL
1431 },
1432 {
1433 0x0000000000000000ULL,
1434 0x0000000000000000ULL,
1435 0x0000000000000000ULL,
1436 0x0000000000000000ULL,
1437 0xFD00000000000000ULL,
1438 0xFDFD000000000000ULL,
1439 0xFDFDFD0000000000ULL,
1440 0xFDFDFDFD00000000ULL
1441 },
1442 {
1443 0x0000000000000000ULL,
1444 0x0000000000000000ULL,
1445 0x0000000000000000ULL,
1446 0xFD00000000000000ULL,
1447 0xFDFD000000000000ULL,
1448 0xFDFDFD0000000000ULL,
1449 0xFDFDFDFD00000000ULL,
1450 0xFDFDFDFDFD000000ULL
1451 },
1452 {
1453 0x0000000000000000ULL,
1454 0x0000000000000000ULL,
1455 0xFD00000000000000ULL,
1456 0xFDFD000000000000ULL,
1457 0xFDFDFD0000000000ULL,
1458 0xFDFDFDFD00000000ULL,
1459 0xFDFDFDFDFD000000ULL,
1460 0xFDFDFDFDFDFD0000ULL
1461 },
1462 {
1463 0x0000000000000000ULL,
1464 0xFD00000000000000ULL,
1465 0xFDFD000000000000ULL,
1466 0xFDFDFD0000000000ULL,
1467 0xFDFDFDFD00000000ULL,
1468 0xFDFDFDFDFD000000ULL,
1469 0xFDFDFDFDFDFD0000ULL,
1470 0xFDFDFDFDFDFDFD00ULL
1471 },
1472 {
1473 0xFD00000000000000ULL,
1474 0xFDFD000000000000ULL,
1475 0xFDFDFD0000000000ULL,
1476 0xFDFDFDFD00000000ULL,
1477 0xFDFDFDFDFD000000ULL,
1478 0xFDFDFDFDFDFD0000ULL,
1479 0xFDFDFDFDFDFDFD00ULL,
1480 0xFDFDFDFDFDFDFDFDULL
1481 },
1482 {
1483 0xFDFD000000000000ULL,
1484 0xFDFDFD0000000000ULL,
1485 0xFDFDFDFD00000000ULL,
1486 0xFDFDFDFDFD000000ULL,
1487 0xFDFDFDFDFDFD0000ULL,
1488 0xFDFDFDFDFDFDFD00ULL,
1489 0xFDFDFDFDFDFDFDFDULL,
1490 0xFDFDFDFDFDFDFDFDULL
1491 },
1492 {
1493 0xFDFDFD0000000000ULL,
1494 0xFDFDFDFD00000000ULL,
1495 0xFDFDFDFDFD000000ULL,
1496 0xFDFDFDFDFDFD0000ULL,
1497 0xFDFDFDFDFDFDFD00ULL,
1498 0xFDFDFDFDFDFDFDFDULL,
1499 0xFDFDFDFDFDFDFDFDULL,
1500 0xFDFDFDFDFDFDFDFDULL
1501 },
1502 {
1503 0xFDFDFDFD00000000ULL,
1504 0xFDFDFDFDFD000000ULL,
1505 0xFDFDFDFDFDFD0000ULL,
1506 0xFDFDFDFDFDFDFD00ULL,
1507 0xFDFDFDFDFDFDFDFDULL,
1508 0xFDFDFDFDFDFDFDFDULL,
1509 0xFDFDFDFDFDFDFDFDULL,
1510 0xFDFDFDFDFDFDFDFDULL
1511 },
1512 {
1513 0xFDFDFDFDFD000000ULL,
1514 0xFDFDFDFDFDFD0000ULL,
1515 0xFDFDFDFDFDFDFD00ULL,
1516 0xFDFDFDFDFDFDFDFDULL,
1517 0xFDFDFDFDFDFDFDFDULL,
1518 0xFDFDFDFDFDFDFDFDULL,
1519 0xFDFDFDFDFDFDFDFDULL,
1520 0xFDFDFDFDFDFDFDFDULL
1521 },
1522 {
1523 0xFDFDFDFDFDFD0000ULL,
1524 0xFDFDFDFDFDFDFD00ULL,
1525 0xFDFDFDFDFDFDFDFDULL,
1526 0xFDFDFDFDFDFDFDFDULL,
1527 0xFDFDFDFDFDFDFDFDULL,
1528 0xFDFDFDFDFDFDFDFDULL,
1529 0xFDFDFDFDFDFDFDFDULL,
1530 0xFDFDFDFDFDFDFDFDULL
1531 },
1532 {
1533 0xFDFDFDFDFDFDFD00ULL,
1534 0xFDFDFDFDFDFDFDFDULL,
1535 0xFDFDFDFDFDFDFDFDULL,
1536 0xFDFDFDFDFDFDFDFDULL,
1537 0xFDFDFDFDFDFDFDFDULL,
1538 0xFDFDFDFDFDFDFDFDULL,
1539 0xFDFDFDFDFDFDFDFDULL,
1540 0xFDFDFDFDFDFDFDFDULL
1541 },
1542 {
1543 0xFDFDFDFDFDFDFDFDULL,
1544 0xFDFDFDFDFDFDFDFDULL,
1545 0xFDFDFDFDFDFDFDFDULL,
1546 0xFDFDFDFDFDFDFDFDULL,
1547 0xFDFDFDFDFDFDFDFDULL,
1548 0xFDFDFDFDFDFDFDFDULL,
1549 0xFDFDFDFDFDFDFDFDULL,
1550 0xFDFDFDFDFDFDFDFDULL
1551 }
1552 },
1553 {
1554 {
1555 0x0000000000000000ULL,
1556 0x0000000000000000ULL,
1557 0x0000000000000000ULL,
1558 0x0000000000000000ULL,
1559 0x0000000000000000ULL,
1560 0x0000000000000000ULL,
1561 0x0000000000000000ULL,
1562 0x0000000000000000ULL
1563 },
1564 {
1565 0x0000000000000000ULL,
1566 0x0000000000000000ULL,
1567 0x0000000000000000ULL,
1568 0x0000000000000000ULL,
1569 0x0000000000000000ULL,
1570 0x0000000000000000ULL,
1571 0x0000000000000000ULL,
1572 0x00000000000000FDULL
1573 },
1574 {
1575 0x0000000000000000ULL,
1576 0x0000000000000000ULL,
1577 0x0000000000000000ULL,
1578 0x0000000000000000ULL,
1579 0x0000000000000000ULL,
1580 0x0000000000000000ULL,
1581 0x00000000000000FDULL,
1582 0x000000000000FDFDULL
1583 },
1584 {
1585 0x0000000000000000ULL,
1586 0x0000000000000000ULL,
1587 0x0000000000000000ULL,
1588 0x0000000000000000ULL,
1589 0x0000000000000000ULL,
1590 0x00000000000000FDULL,
1591 0x000000000000FDFDULL,
1592 0x0000000000FDFDFDULL
1593 },
1594 {
1595 0x0000000000000000ULL,
1596 0x0000000000000000ULL,
1597 0x0000000000000000ULL,
1598 0x0000000000000000ULL,
1599 0x00000000000000FDULL,
1600 0x000000000000FDFDULL,
1601 0x0000000000FDFDFDULL,
1602 0x00000000FDFDFDFDULL
1603 },
1604 {
1605 0x0000000000000000ULL,
1606 0x0000000000000000ULL,
1607 0x0000000000000000ULL,
1608 0x00000000000000FDULL,
1609 0x000000000000FDFDULL,
1610 0x0000000000FDFDFDULL,
1611 0x00000000FDFDFDFDULL,
1612 0x000000FDFDFDFDFDULL
1613 },
1614 {
1615 0x0000000000000000ULL,
1616 0x0000000000000000ULL,
1617 0x00000000000000FDULL,
1618 0x000000000000FDFDULL,
1619 0x0000000000FDFDFDULL,
1620 0x00000000FDFDFDFDULL,
1621 0x000000FDFDFDFDFDULL,
1622 0x0000FDFDFDFDFDFDULL
1623 },
1624 {
1625 0x0000000000000000ULL,
1626 0x00000000000000FDULL,
1627 0x000000000000FDFDULL,
1628 0x0000000000FDFDFDULL,
1629 0x00000000FDFDFDFDULL,
1630 0x000000FDFDFDFDFDULL,
1631 0x0000FDFDFDFDFDFDULL,
1632 0x00FDFDFDFDFDFDFDULL
1633 },
1634 {
1635 0x00000000000000FDULL,
1636 0x000000000000FDFDULL,
1637 0x0000000000FDFDFDULL,
1638 0x00000000FDFDFDFDULL,
1639 0x000000FDFDFDFDFDULL,
1640 0x0000FDFDFDFDFDFDULL,
1641 0x00FDFDFDFDFDFDFDULL,
1642 0xFDFDFDFDFDFDFDFDULL
1643 },
1644 {
1645 0x000000000000FDFDULL,
1646 0x0000000000FDFDFDULL,
1647 0x00000000FDFDFDFDULL,
1648 0x000000FDFDFDFDFDULL,
1649 0x0000FDFDFDFDFDFDULL,
1650 0x00FDFDFDFDFDFDFDULL,
1651 0xFDFDFDFDFDFDFDFDULL,
1652 0xFDFDFDFDFDFDFDFDULL
1653 },
1654 {
1655 0x0000000000FDFDFDULL,
1656 0x00000000FDFDFDFDULL,
1657 0x000000FDFDFDFDFDULL,
1658 0x0000FDFDFDFDFDFDULL,
1659 0x00FDFDFDFDFDFDFDULL,
1660 0xFDFDFDFDFDFDFDFDULL,
1661 0xFDFDFDFDFDFDFDFDULL,
1662 0xFDFDFDFDFDFDFDFDULL
1663 },
1664 {
1665 0x00000000FDFDFDFDULL,
1666 0x000000FDFDFDFDFDULL,
1667 0x0000FDFDFDFDFDFDULL,
1668 0x00FDFDFDFDFDFDFDULL,
1669 0xFDFDFDFDFDFDFDFDULL,
1670 0xFDFDFDFDFDFDFDFDULL,
1671 0xFDFDFDFDFDFDFDFDULL,
1672 0xFDFDFDFDFDFDFDFDULL
1673 },
1674 {
1675 0x000000FDFDFDFDFDULL,
1676 0x0000FDFDFDFDFDFDULL,
1677 0x00FDFDFDFDFDFDFDULL,
1678 0xFDFDFDFDFDFDFDFDULL,
1679 0xFDFDFDFDFDFDFDFDULL,
1680 0xFDFDFDFDFDFDFDFDULL,
1681 0xFDFDFDFDFDFDFDFDULL,
1682 0xFDFDFDFDFDFDFDFDULL
1683 },
1684 {
1685 0x0000FDFDFDFDFDFDULL,
1686 0x00FDFDFDFDFDFDFDULL,
1687 0xFDFDFDFDFDFDFDFDULL,
1688 0xFDFDFDFDFDFDFDFDULL,
1689 0xFDFDFDFDFDFDFDFDULL,
1690 0xFDFDFDFDFDFDFDFDULL,
1691 0xFDFDFDFDFDFDFDFDULL,
1692 0xFDFDFDFDFDFDFDFDULL
1693 },
1694 {
1695 0x00FDFDFDFDFDFDFDULL,
1696 0xFDFDFDFDFDFDFDFDULL,
1697 0xFDFDFDFDFDFDFDFDULL,
1698 0xFDFDFDFDFDFDFDFDULL,
1699 0xFDFDFDFDFDFDFDFDULL,
1700 0xFDFDFDFDFDFDFDFDULL,
1701 0xFDFDFDFDFDFDFDFDULL,
1702 0xFDFDFDFDFDFDFDFDULL
1703 },
1704 {
1705 0xFDFDFDFDFDFDFDFDULL,
1706 0xFDFDFDFDFDFDFDFDULL,
1707 0xFDFDFDFDFDFDFDFDULL,
1708 0xFDFDFDFDFDFDFDFDULL,
1709 0xFDFDFDFDFDFDFDFDULL,
1710 0xFDFDFDFDFDFDFDFDULL,
1711 0xFDFDFDFDFDFDFDFDULL,
1712 0xFDFDFDFDFDFDFDFDULL
1713 }
1714 }
1715 };
1716
1717 int32_t black_opening_count=0;
1718 int32_t black_opening_x,black_opening_y;
1719 int32_t black_opening_shape;
1720
1721 979 int32_t choose_opening_shape()
1722 {
1723 // First, count how many bits are set
1724 979 int32_t numBits=0;
1725 int32_t bitCounter;
1726
1727
2/2
✓ Branch 0 taken 4895 times.
✓ Branch 1 taken 979 times.
5874 for(int32_t i=0; i<bosMAX; i++)
1728 {
1729
2/2
✓ Branch 0 taken 3700 times.
✓ Branch 1 taken 1195 times.
4895 if(COOLSCROLL&(1<<i))
1730 1195 numBits++;
1731 4895 }
1732
1733 // Shouldn't happen...
1734
1/2
✓ Branch 0 taken 979 times.
✗ Branch 1 not taken.
979 if(numBits==0)
1735 return bosCIRCLE;
1736
1737 // Pick a bit
1738 979 bitCounter=zc_rand()%numBits+1;
1739
1740
2/2
✓ Branch 0 taken 1191 times.
✓ Branch 1 taken 26 times.
1217 for(int32_t i=0; i<bosMAX; i++)
1741 {
1742 // If this bit is set, decrement the bit counter
1743
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 1109 times.
1191 if(COOLSCROLL&(1<<i))
1744 1109 bitCounter--;
1745
1746 // When the counter hits 0, return a value based on
1747 // which bit it stopped on.
1748 // Reminder: enum {bosCIRCLE=0, bosOVAL, bosTRIANGLE, bosSMAS, bosFADEBLACK, bosMAX};
1749
2/2
✓ Branch 0 taken 953 times.
✓ Branch 1 taken 238 times.
1191 if(bitCounter==0)
1750 953 return i;
1751 238 }
1752
1753 // Shouldn't be necessary, but the compiler might complain, at least
1754 26 return bosCIRCLE;
1755 979 }
1756
1757 276 void close_black_opening(int32_t x, int32_t y, bool wait, int32_t shape)
1758 {
1759
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 276 times.
276 black_opening_shape= (shape>-1 ? shape : choose_opening_shape());
1760
1761 276 int32_t w=256, h=224;
1762 276 int32_t blockrows=28, blockcolumns=32;
1763 276 int32_t xoffset=(x-(w/2))/8, yoffset=(y-(h/2))/8;
1764
1765
2/2
✓ Branch 0 taken 7728 times.
✓ Branch 1 taken 276 times.
8004 for(int32_t blockrow=0; blockrow<blockrows; ++blockrow) //30
1766 {
1767
2/2
✓ Branch 0 taken 247296 times.
✓ Branch 1 taken 7728 times.
255024 for(int32_t blockcolumn=0; blockcolumn<blockcolumns; ++blockcolumn) //40
1768 {
1769
2/2
✓ Branch 0 taken 132516 times.
✓ Branch 1 taken 114780 times.
247296 screen_triangles[blockrow][blockcolumn]=zc_max(abs(int32_t(double(blockcolumns-1)/2-blockcolumn+xoffset)),abs(int32_t(double(blockrows-1)/2-blockrow+yoffset)))|0x0100|((blockrow-yoffset<blockrows/2)?0:0x8000)|((blockcolumn-xoffset<blockcolumns/2)?0x4000:0);
1770 247296 }
1771 7728 }
1772
1773 276 black_opening_count = 66;
1774 276 black_opening_x = x;
1775 276 black_opening_y = y;
1776 276 lensclk = 0;
1777 //black_opening_shape=(black_opening_shape+1)%bosMAX;
1778
1779
1780
1/2
✓ Branch 0 taken 276 times.
✗ Branch 1 not taken.
276 if(black_opening_shape == bosFADEBLACK)
1781 {
1782 refreshTints();
1783 memcpy(tempblackpal, RAMpal, sizeof(RAMpal)); //Store palette in temp palette for fade effect
1784 }
1785
1/2
✓ Branch 0 taken 276 times.
✗ Branch 1 not taken.
276 if(wait)
1786 {
1787 FFCore.warpScriptCheck();
1788 for(int32_t i=0; i<66; i++)
1789 {
1790 draw_screen(tmpscr);
1791 //put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,false,sspUP);
1792 advanceframe(true);
1793
1794 if(Quit)
1795 {
1796 break;
1797 }
1798 }
1799 }
1800 276 }
1801
1802 703 void open_black_opening(int32_t x, int32_t y, bool wait, int32_t shape)
1803 {
1804
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 703 times.
703 black_opening_shape= (shape>-1 ? shape : choose_opening_shape());
1805
1806 703 int32_t w=256, h=224;
1807 703 int32_t blockrows=28, blockcolumns=32;
1808 703 int32_t xoffset=(x-(w/2))/8, yoffset=(y-(h/2))/8;
1809
1810
2/2
✓ Branch 0 taken 19684 times.
✓ Branch 1 taken 703 times.
20387 for(int32_t blockrow=0; blockrow<blockrows; ++blockrow) //30
1811 {
1812
2/2
✓ Branch 0 taken 629888 times.
✓ Branch 1 taken 19684 times.
649572 for(int32_t blockcolumn=0; blockcolumn<blockcolumns; ++blockcolumn) //40
1813 {
1814
2/2
✓ Branch 0 taken 289862 times.
✓ Branch 1 taken 340026 times.
629888 screen_triangles[blockrow][blockcolumn]=zc_max(abs(int32_t(double(blockcolumns-1)/2-blockcolumn+xoffset)),abs(int32_t(double(blockrows-1)/2-blockrow+yoffset)))|0x0100|((blockrow-yoffset<blockrows/2)?0:0x8000)|((blockcolumn-xoffset<blockcolumns/2)?0x4000:0);
1815 629888 }
1816 19684 }
1817
1818 703 black_opening_count = -66;
1819 703 black_opening_x = x;
1820 703 black_opening_y = y;
1821 703 lensclk = 0;
1822
1/2
✓ Branch 0 taken 703 times.
✗ Branch 1 not taken.
703 if(black_opening_shape == bosFADEBLACK)
1823 {
1824 refreshTints();
1825 memcpy(tempblackpal, RAMpal, sizeof(RAMpal)); //Store palette in temp palette for fade effect
1826 }
1827
2/2
✓ Branch 0 taken 156 times.
✓ Branch 1 taken 547 times.
703 if(wait)
1828 {
1829 547 FFCore.warpScriptCheck();
1830
2/2
✓ Branch 0 taken 547 times.
✓ Branch 1 taken 36102 times.
36649 for(int32_t i=0; i<66; i++)
1831 {
1832 36102 draw_screen(tmpscr);
1833 //put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,false,sspUP);
1834 36102 advanceframe(true);
1835
1836
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 36102 times.
36102 if(Quit)
1837 {
1838 break;
1839 }
1840 36102 }
1841 547 }
1842 703 }
1843
1844 64614 void black_opening(BITMAP *dest,int32_t x,int32_t y,int32_t a,int32_t max_a)
1845 {
1846 64614 clear_to_color(tmp_scr,BLACK);
1847 64614 int32_t w=256, h=224;
1848
1849
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 858 times.
✓ Branch 2 taken 660 times.
✓ Branch 3 taken 1650 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 61446 times.
64614 switch(black_opening_shape)
1850 {
1851 case bosOVAL:
1852 {
1853 858 double new_w=(w/2)+abs(w/2-x);
1854 858 double new_h=(h/2)+abs(h/2-y);
1855 858 double b=sqrt(((new_w*new_w)/4)+(new_h*new_h));
1856 858 ellipsefill(tmp_scr,x,y,int32_t(2*a*b/max_a)/8*8,int32_t(a*b/max_a)/8*8,0);
1857 858 break;
1858 }
1859
1860 case bosTRIANGLE:
1861 {
1862 660 double new_w=(w/2)+abs(w/2-x);
1863 660 double new_h=(h/2)+abs(h/2-y);
1864 660 double r=a*(new_w*sqrt((double)3)+new_h)/max_a;
1865 660 double P2= (PI/2);
1866 660 double P23=(2*PI/3);
1867 660 double P43=(4*PI/3);
1868 660 double Pa= (-4*PI*a/(3*max_a));
1869 660 double angle=P2+Pa;
1870 660 double a0=angle;
1871 660 double a2=angle+P23;
1872 660 double a4=angle+P43;
1873 1320 triangle(tmp_scr, x+int32_t(zc::math::Cos(a0)*r), y-int32_t(zc::math::Sin(a0)*r),
1874 660 x+int32_t(zc::math::Cos(a2)*r), y-int32_t(zc::math::Sin(a2)*r),
1875 660 x+int32_t(zc::math::Cos(a4)*r), y-int32_t(zc::math::Sin(a4)*r),
1876 0);
1877 660 break;
1878 }
1879
1880 case bosSMAS:
1881 {
1882
2/2
✓ Branch 0 taken 660 times.
✓ Branch 1 taken 990 times.
1650 int32_t distance=zc_max(abs(w/2-x),abs(h/2-y))/8;
1883
1884
2/2
✓ Branch 0 taken 46200 times.
✓ Branch 1 taken 1650 times.
47850 for(int32_t blockrow=0; blockrow<28; ++blockrow) //30
1885 {
1886
2/2
✓ Branch 0 taken 369600 times.
✓ Branch 1 taken 46200 times.
415800 for(int32_t linerow=0; linerow<8; ++linerow)
1887 {
1888 369600 qword *triangleline=(qword*)(tmp_scr->line[(blockrow*8+linerow)]);
1889
1890
2/2
✓ Branch 0 taken 11827200 times.
✓ Branch 1 taken 369600 times.
12196800 for(int32_t blockcolumn=0; blockcolumn<32; ++blockcolumn) //40
1891 {
1892 35481600 *triangleline=triangles[(screen_triangles[blockrow][blockcolumn]&0xC000)>>14]
1893
6/6
✓ Branch 0 taken 8249728 times.
✓ Branch 1 taken 3577472 times.
✓ Branch 2 taken 7829672 times.
✓ Branch 3 taken 3997528 times.
✓ Branch 4 taken 4252200 times.
✓ Branch 5 taken 3577472 times.
11827200 [zc_min(zc_max((((31+distance)*(max_a-a)/max_a)+((screen_triangles[blockrow][blockcolumn]&0x0FFF)-0x0100)-(15+distance)),0),15)]
1894 11827200 [linerow];
1895 11827200 ++triangleline;
1896
1897
2/2
✓ Branch 0 taken 10348800 times.
✓ Branch 1 taken 1478400 times.
11827200 if(linerow==0)
1898 {
1899 1478400 }
1900 11827200 }
1901 369600 }
1902 46200 }
1903
1904 1650 break;
1905 }
1906
1907 case bosFADEBLACK:
1908 {
1909 if(black_opening_count<0)
1910 {
1911 black_fade(zc_min(-black_opening_count,63));
1912 }
1913 else if(black_opening_count>0)
1914 {
1915 black_fade(63-zc_max(black_opening_count-3,0));
1916 }
1917 else black_fade(0);
1918 return; //no blitting from tmp_scr!
1919 }
1920
1921 61446 case bosCIRCLE:
1922 default:
1923 {
1924 61446 double new_w=(w/2)+abs(w/2-x);
1925 61446 double new_h=(h/2)+abs(h/2-y);
1926 61446 int32_t r=int32_t(sqrt((new_w*new_w)+(new_h*new_h))*a/max_a);
1927 //circlefill(tmp_scr,x,y,a<<3,0);
1928 61446 circlefill(tmp_scr,x,y,r,0);
1929 61446 break;
1930 }
1931 }
1932
1933 64614 masked_blit(tmp_scr,dest,0,0,0,0,320,240);
1934 64614 }
1935
1936
1937 void black_fade(int32_t fadeamnt)
1938 {
1939 for(int32_t i=0; i < 0xEF; i++)
1940 {
1941 RAMpal[i].r = vbound(tempblackpal[i].r-fadeamnt,0,63);
1942 RAMpal[i].g = vbound(tempblackpal[i].g-fadeamnt,0,63);
1943 RAMpal[i].b = vbound(tempblackpal[i].b-fadeamnt,0,63);
1944 }
1945
1946 refreshpal = true;
1947 }
1948
1949 //----------------------------------------------------------------
1950
1951 17710096 bool item_disabled(int32_t item) //is this item disabled?
1952 {
1953
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17710096 times.
17710096 return (item>=0 && game->items_off[item] != 0);
1954 }
1955
1956 6255715 bool can_use_item(int32_t item_type, int32_t item) //can Hero use this item?
1957 {
1958
2/2
✓ Branch 0 taken 57842 times.
✓ Branch 1 taken 6197873 times.
6255715 if(current_item(item_type, true) >=item)
1959 {
1960 57842 return true;
1961 }
1962
1963 6197873 return false;
1964 6255715 }
1965
1966 26033259 bool has_item(int32_t item_type, int32_t it) //does Hero possess this item?
1967 {
1968
5/9
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 4763517 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2908079 times.
✓ Branch 6 taken 13819262 times.
✓ Branch 7 taken 4510595 times.
✓ Branch 8 taken 31806 times.
26033259 switch(item_type)
1969 {
1970 case itype_bomb:
1971 case itype_sbomb:
1972 {
1973 int32_t itemid = getItemID(itemsbuf, item_type, it);
1974
1975 if(itemid == -1)
1976 return false;
1977
1978 return (game->get_item(itemid));
1979 }
1980
1981 case itype_clock:
1982 {
1983 4763517 int32_t itemid = getItemID(itemsbuf, item_type, it);
1984
1985
2/4
✓ Branch 0 taken 4763517 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4763517 times.
✗ Branch 3 not taken.
4763517 if(itemid != -1 && (itemsbuf[itemid].flags & ITEM_FLAG1)) //Active clock
1986 return (game->get_item(itemid));
1987 4763517 return Hero.getClock()?1:0;
1988 }
1989
1990 case itype_key:
1991 return (game->get_keys()>0);
1992
1993 case itype_magiccontainer:
1994 return (game->get_maxmagic()>=game->get_mp_per_block());
1995
1996 case itype_triforcepiece: //it: -2=any, -1=current level, other=that level
1997 {
1998
1/3
✓ Branch 0 taken 2908079 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
2908079 switch(it)
1999 {
2000 case -2:
2001 {
2002 for(int32_t i=0; i<MAXLEVELS; i++)
2003 {
2004 if(game->lvlitems[i]&liTRIFORCE)
2005 {
2006 return true;
2007 }
2008 }
2009
2010 return false;
2011 }
2012
2013 case -1:
2014 return (game->lvlitems[dlevel]&liTRIFORCE);
2015
2016 default:
2017
2/4
✓ Branch 0 taken 2908079 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2908079 times.
2908079 if(it>=0&&it<MAXLEVELS)
2018 {
2019 2908079 return (game->lvlitems[it]&liTRIFORCE);
2020 }
2021
2022 break;
2023 }
2024
2025 return 0;
2026 }
2027
2028 case itype_map: //it: -2=any, -1=current level, other=that level
2029 {
2030
1/3
✓ Branch 0 taken 13819262 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
13819262 switch(it)
2031 {
2032 case -2:
2033 {
2034 for(int32_t i=0; i<MAXLEVELS; i++)
2035 {
2036 if(game->lvlitems[i]&liMAP)
2037 {
2038 return true;
2039 }
2040 }
2041
2042 return false;
2043 }
2044
2045 case -1:
2046 return (game->lvlitems[dlevel]&liMAP)!=0;
2047
2048 default:
2049
2/4
✓ Branch 0 taken 13819262 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 13819262 times.
13819262 if(it>=0&&it<MAXLEVELS)
2050 {
2051 13819262 return (game->lvlitems[it]&liMAP)!=0;
2052 }
2053
2054 break;
2055 }
2056
2057 return 0;
2058 }
2059
2060 case itype_compass: //it: -2=any, -1=current level, other=that level
2061 {
2062
1/3
✓ Branch 0 taken 4510595 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
4510595 switch(it)
2063 {
2064 case -2:
2065 {
2066 for(int32_t i=0; i<MAXLEVELS; i++)
2067 {
2068 if(game->lvlitems[i]&liCOMPASS)
2069 {
2070 return true;
2071 }
2072 }
2073
2074 return false;
2075 }
2076
2077 case -1:
2078 return (game->lvlitems[dlevel]&liCOMPASS)!=0;
2079
2080 default:
2081
2/4
✓ Branch 0 taken 4510595 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4510595 times.
✗ Branch 3 not taken.
4510595 if(it>=0&&it<MAXLEVELS)
2082 {
2083 4510595 return (game->lvlitems[it]&liCOMPASS)!=0;
2084 }
2085
2086 break;
2087 }
2088 return 0;
2089 }
2090
2091 case itype_bosskey: //it: -2=any, -1=current level, other=that level
2092 {
2093
1/3
✓ Branch 0 taken 31806 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
31806 switch(it)
2094 {
2095 case -2:
2096 {
2097 for(int32_t i=0; i<MAXLEVELS; i++)
2098 {
2099 if(game->lvlitems[i]&liBOSSKEY)
2100 {
2101 return true;
2102 }
2103 }
2104
2105 return false;
2106 }
2107
2108 case -1:
2109 return (game->lvlitems[dlevel]&liBOSSKEY)?1:0;
2110
2111 default:
2112
2/4
✓ Branch 0 taken 31806 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 31806 times.
31806 if(it>=0&&it<MAXLEVELS)
2113 {
2114 31806 return (game->lvlitems[it]&liBOSSKEY)?1:0;
2115 }
2116 break;
2117 }
2118 return 0;
2119 }
2120
2121 default:
2122 //it=(1<<(it-1));
2123 /*if (item_type>=itype_max)
2124 {
2125 system_pal();
2126 jwin_alert("Error","has_item exception",NULL,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont));
2127 game_pal();
2128
2129 return false;
2130 }*/
2131 int32_t itemid = getItemID(itemsbuf, item_type, it);
2132
2133 if(itemid == -1)
2134 return false;
2135
2136 return game->get_item(itemid);
2137 }
2138 26033259 }
2139
2140
2141 80974509 int32_t current_item(int32_t item_type, bool checkenabled) //item currently being used
2142 {
2143
9/9
✓ Branch 0 taken 4763517 times.
✓ Branch 1 taken 42866373 times.
✓ Branch 2 taken 4763517 times.
✓ Branch 3 taken 4763517 times.
✓ Branch 4 taken 4763517 times.
✓ Branch 5 taken 4763517 times.
✓ Branch 6 taken 4763517 times.
✓ Branch 7 taken 4763517 times.
✓ Branch 8 taken 4763517 times.
80974509 switch(item_type)
2144 {
2145 case itype_clock:
2146 {
2147 4763517 int32_t maxid = getHighestLevelOfFamily(game, itemsbuf, item_type, checkenabled);
2148
2149
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4763517 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4763517 if(maxid != -1 && (itemsbuf[maxid].flags & ITEM_FLAG1)) //Active clock
2150 return itemsbuf[maxid].fam_type;
2151
2152 4763517 return has_item(itype_clock,1) ? 1 : 0;
2153 }
2154
2155 case itype_key:
2156 4763517 return game->get_keys();
2157
2158 case itype_lkey:
2159 4763517 return game->lvlkeys[get_dlevel()];
2160
2161 case itype_magiccontainer:
2162 4763517 return game->get_maxmagic()/game->get_mp_per_block();
2163
2164 case itype_triforcepiece:
2165 {
2166 4763517 int32_t count=0;
2167
2168
2/2
✓ Branch 0 taken 2438920704 times.
✓ Branch 1 taken 4763517 times.
2443684221 for(int32_t i=0; i<MAXLEVELS; i++)
2169 {
2170 2438920704 count+=(game->lvlitems[i]&liTRIFORCE)?1:0;
2171 2438920704 }
2172
2173 4763517 return count;
2174 }
2175
2176 case itype_map:
2177 {
2178 4763517 int32_t count=0;
2179
2180
2/2
✓ Branch 0 taken 2438920704 times.
✓ Branch 1 taken 4763517 times.
2443684221 for(int32_t i=0; i<MAXLEVELS; i++)
2181 {
2182 2438920704 count+=(game->lvlitems[i]&liMAP)?1:0;
2183 2438920704 }
2184
2185 4763517 return count;
2186 }
2187
2188 case itype_compass:
2189 {
2190 4763517 int32_t count=0;
2191
2192
2/2
✓ Branch 0 taken 2438920704 times.
✓ Branch 1 taken 4763517 times.
2443684221 for(int32_t i=0; i<MAXLEVELS; i++)
2193 {
2194 2438920704 count+=(game->lvlitems[i]&liCOMPASS)?1:0;
2195 2438920704 }
2196
2197 4763517 return count;
2198 }
2199
2200 case itype_bosskey:
2201 {
2202 4763517 int32_t count=0;
2203
2204
2/2
✓ Branch 0 taken 2438920704 times.
✓ Branch 1 taken 4763517 times.
2443684221 for(int32_t i=0; i<MAXLEVELS; i++)
2205 {
2206 2438920704 count+=(game->lvlitems[i]&liBOSSKEY)?1:0;
2207 2438920704 }
2208
2209 4763517 return count;
2210 }
2211
2212 default:
2213 42866373 int32_t maxid = getHighestLevelOfFamily(game, itemsbuf, item_type, checkenabled);
2214
2215
2/2
✓ Branch 0 taken 8091859 times.
✓ Branch 1 taken 34774514 times.
42866373 if(maxid == -1)
2216 34774514 return 0;
2217
2218 8091859 return itemsbuf[maxid].fam_type;
2219 }
2220 80974509 }
2221
2222 74718794 int32_t current_item(int32_t item_type) //item currently being used
2223 {
2224 74718794 return current_item(item_type, true);
2225 }
2226
2227 31 std::map<int32_t, int32_t> itemcache;
2228
2229 // Not actually used by anything at the moment...
2230 void removeFromItemCache(int32_t itemid)
2231 {
2232 itemcache.erase(itemid);
2233 }
2234
2235 22166 void flushItemCache()
2236 {
2237 22166 itemcache.clear();
2238
2239 //also fix the active subscreen if items were deleted -DD
2240
1/2
✓ Branch 0 taken 22166 times.
✗ Branch 1 not taken.
22166 if(game != NULL)
2241 {
2242 22166 verifyBothWeapons();
2243 22166 load_Sitems(&QMisc);
2244 22166 }
2245 22166 }
2246
2247 // This is used often, so it should be as direct as possible.
2248 2654900809 int32_t _c_item_id_internal(int32_t itemtype, bool checkmagic, bool jinx_check)
2249 {
2250
2/2
✓ Branch 0 taken 2599092323 times.
✓ Branch 1 taken 55808486 times.
2654900809 if(jinx_check)
2251 {
2252
4/4
✓ Branch 0 taken 35647284 times.
✓ Branch 1 taken 20161202 times.
✓ Branch 2 taken 32240842 times.
✓ Branch 3 taken 3406442 times.
55808486 if(!(HeroSwordClk() || HeroItemClk()))
2253 32240842 jinx_check = false; //not jinxed
2254 55808486 }
2255
4/4
✓ Branch 0 taken 2632533202 times.
✓ Branch 1 taken 22367607 times.
✓ Branch 2 taken 23398308 times.
✓ Branch 3 taken 2609134894 times.
2654900809 if(itemtype!=itype_ring && !jinx_check) // Rings must always be checked, as must jinx checks...
2256 {
2257 2609134894 std::map<int32_t,int32_t>::iterator res = itemcache.find(itemtype);
2258
2259
2/2
✓ Branch 0 taken 2597818357 times.
✓ Branch 1 taken 11316537 times.
2609134894 if(res != itemcache.end())
2260 2597818357 return res->second;
2261 11316537 }
2262
2263 57082452 int32_t result = -1;
2264 57082452 int32_t highestlevel = -1;
2265
2266
2/2
✓ Branch 0 taken 14613107712 times.
✓ Branch 1 taken 57082452 times.
14670190164 for(int32_t i=0; i<MAXITEMS; i++)
2267 {
2268
5/6
✓ Branch 0 taken 1152266635 times.
✓ Branch 1 taken 13460841077 times.
✓ Branch 2 taken 17146122 times.
✓ Branch 3 taken 1135120513 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 17146122 times.
14613107712 if(game->get_item(i) && itemsbuf[i].family==itemtype && !item_disabled(i))
2269 {
2270
4/4
✓ Branch 0 taken 5098282 times.
✓ Branch 1 taken 12047840 times.
✓ Branch 2 taken 1326295 times.
✓ Branch 3 taken 15819827 times.
17146122 if((checkmagic || itemtype == itype_ring) && itemtype != itype_magicring)
2271 {
2272 //printf("Checkmagic for %d: %d (%d %d)\n",i,checkmagiccost(i),itemsbuf[i].magic*game->get_magicdrainrate(),game->get_magic());
2273
2/2
✓ Branch 0 taken 15819671 times.
✓ Branch 1 taken 156 times.
15819827 if(!checkmagiccost(i))
2274 {
2275
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 144 times.
156 if ( !get_bit(quest_rules,qr_NEVERDISABLEAMMOONSUBSCREEN) ) continue; //don't make items with a magic cost vanish!! -Z
2276 12 }
2277 15819683 }
2278
6/6
✓ Branch 0 taken 14774115 times.
✓ Branch 1 taken 2371863 times.
✓ Branch 2 taken 256688 times.
✓ Branch 3 taken 2115175 times.
✓ Branch 4 taken 1627257 times.
✓ Branch 5 taken 744606 times.
17145978 if(jinx_check && (usesSwordJinx(i) ? HeroSwordClk() : HeroItemClk()))
2279 {
2280
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 744606 times.
744606 if(!(itemsbuf[i].flags & ITEM_JINX_IMMUNE))
2281 744606 continue;
2282 }
2283
2284
2/2
✓ Branch 0 taken 237664 times.
✓ Branch 1 taken 16163708 times.
16401372 if(itemsbuf[i].fam_type >= highestlevel)
2285 {
2286 16163708 highestlevel = itemsbuf[i].fam_type;
2287 16163708 result=i;
2288 16163708 }
2289 16401372 }
2290 14612362962 }
2291
2292
2/2
✓ Branch 0 taken 23567644 times.
✓ Branch 1 taken 33514808 times.
57082452 if(!jinx_check) //Can't cache jinx_check results
2293 33514808 itemcache[itemtype] = result;
2294 57082452 return result;
2295 2654900809 }
2296
2297 // 'jinx_check' indicates that the highest level item *immune to jinxes* should be returned.
2298 2631647827 int32_t current_item_id(int32_t itemtype, bool checkmagic, bool jinx_check)
2299 {
2300 2631647827 auto ret = _c_item_id_internal(itemtype,checkmagic,jinx_check);
2301
2/2
✓ Branch 0 taken 32555504 times.
✓ Branch 1 taken 2599092323 times.
2631647827 if(!jinx_check) //If not already a jinx-immune-only check...
2302 {
2303 //And the player IS jinxed...
2304
4/4
✓ Branch 0 taken 2579196705 times.
✓ Branch 1 taken 19895618 times.
✓ Branch 2 taken 3357364 times.
✓ Branch 3 taken 2575839341 times.
2599092323 if(HeroSwordClk() || HeroItemClk())
2305 {
2306 //Then do a jinx-immune-only check here
2307 23252982 auto ret2 = _c_item_id_internal(itemtype,checkmagic,true);
2308 //And *IF IT FINDS A VALID ITEM*, return that one instead! -Em
2309 //Should NOT need a compat rule, as this should always return -1 in old quests.
2310
2/2
✓ Branch 0 taken 1102644 times.
✓ Branch 1 taken 22150338 times.
23252982 if(ret2 > -1) return ret2;
2311 22150338 }
2312 2597989679 }
2313 2630545183 return ret;
2314 2631647827 }
2315 16719493 int32_t current_item_power(int32_t itemtype)
2316 {
2317 16719493 int32_t result = current_item_id(itemtype,true);
2318
2/2
✓ Branch 0 taken 12506683 times.
✓ Branch 1 taken 4212810 times.
16719493 return (result<0) ? 0 : itemsbuf[result].power;
2319 }
2320
2321 7 int32_t heart_container_id()
2322 {
2323
1/2
✓ Branch 0 taken 203 times.
✗ Branch 1 not taken.
203 for(int32_t i=0; i<MAXITEMS; i++)
2324 {
2325
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 196 times.
203 if(itemsbuf[i].family == itype_heartcontainer)
2326 {
2327 7 return i;
2328 }
2329 196 }
2330 return -1;
2331 7 }
2332
2333 4763517 int32_t item_tile_mod()
2334 {
2335 4763517 int32_t tile=0;
2336
2337
2/2
✓ Branch 0 taken 1020710 times.
✓ Branch 1 taken 3742807 times.
4763517 if(game->get_bombs())
2338 {
2339 3742807 int32_t itemid = current_item_id(itype_bomb,false);
2340
3/4
✓ Branch 0 taken 3661748 times.
✓ Branch 1 taken 81059 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3661748 times.
3742807 if(itemid > -1 && checkbunny(itemid))
2341 3661748 tile+=itemsbuf[itemid].ltm;
2342 3742807 }
2343
2344
2/2
✓ Branch 0 taken 3698261 times.
✓ Branch 1 taken 1065256 times.
4763517 if(game->get_sbombs())
2345 {
2346 1065256 int32_t itemid = current_item_id(itype_sbomb,false);
2347
3/4
✓ Branch 0 taken 1063828 times.
✓ Branch 1 taken 1428 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1063828 times.
1065256 if(itemid > -1 && checkbunny(itemid))
2348 1063828 tile+=itemsbuf[itemid].ltm;
2349 1065256 }
2350
2351
2/2
✓ Branch 0 taken 4661760 times.
✓ Branch 1 taken 101757 times.
4763517 if(current_item(itype_clock))
2352 {
2353 101757 int32_t itemid =
2354
1/2
✓ Branch 0 taken 101757 times.
✗ Branch 1 not taken.
101757 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2355 ? iClock
2356 : getHighestLevelEvenUnowned(itemsbuf, itype_clock);
2357
2/4
✓ Branch 0 taken 101757 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 101757 times.
101757 if(itemid > -1 && checkbunny(itemid))
2358 101757 tile+=itemsbuf[itemid].ltm;
2359 101757 }
2360
2361
2/2
✓ Branch 0 taken 3851797 times.
✓ Branch 1 taken 911720 times.
4763517 if(current_item(itype_key))
2362 {
2363 911720 int32_t itemid =
2364
1/2
✓ Branch 0 taken 911720 times.
✗ Branch 1 not taken.
911720 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2365 ? iKey
2366 : getHighestLevelEvenUnowned(itemsbuf, itype_key);
2367
2/4
✓ Branch 0 taken 911720 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 911720 times.
911720 if(itemid > -1 && checkbunny(itemid))
2368 911720 tile+=itemsbuf[itemid].ltm;
2369 911720 }
2370
2371
2/2
✓ Branch 0 taken 4604264 times.
✓ Branch 1 taken 159253 times.
4763517 if(current_item(itype_lkey))
2372 {
2373 159253 int32_t itemid =
2374
2/2
✓ Branch 0 taken 158343 times.
✓ Branch 1 taken 910 times.
159253 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2375 ? iLevelKey
2376 910 : getHighestLevelEvenUnowned(itemsbuf, itype_lkey);
2377
2/4
✓ Branch 0 taken 159253 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 159253 times.
159253 if(itemid > -1 && checkbunny(itemid))
2378 159253 tile+=itemsbuf[itemid].ltm;
2379 159253 }
2380
2381
2/2
✓ Branch 0 taken 990532 times.
✓ Branch 1 taken 3772985 times.
4763517 if(current_item(itype_map))
2382 {
2383 3772985 int32_t itemid =
2384
2/2
✓ Branch 0 taken 3772199 times.
✓ Branch 1 taken 786 times.
3772985 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2385 ? iMap
2386 786 : getHighestLevelEvenUnowned(itemsbuf, itype_map);
2387
2/4
✓ Branch 0 taken 3772985 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 3772985 times.
3772985 if(itemid > -1 && checkbunny(itemid))
2388 3772985 tile+=itemsbuf[itemid].ltm;
2389 3772985 }
2390
2391
2/2
✓ Branch 0 taken 943436 times.
✓ Branch 1 taken 3820081 times.
4763517 if(current_item(itype_compass))
2392 {
2393 3820081 int32_t itemid =
2394
2/2
✓ Branch 0 taken 3739022 times.
✓ Branch 1 taken 81059 times.
3820081 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2395 ? iCompass
2396 81059 : getHighestLevelEvenUnowned(itemsbuf, itype_compass);
2397
2/4
✓ Branch 0 taken 3820081 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 3820081 times.
3820081 if(itemid > -1 && checkbunny(itemid))
2398 3820081 tile+=itemsbuf[itemid].ltm;
2399 3820081 }
2400
2401
2/2
✓ Branch 0 taken 2894313 times.
✓ Branch 1 taken 1869204 times.
4763517 if(current_item(itype_bosskey))
2402 {
2403 1869204 int32_t itemid =
2404
1/2
✓ Branch 0 taken 1869204 times.
✗ Branch 1 not taken.
1869204 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2405 ? iBossKey
2406 : getHighestLevelEvenUnowned(itemsbuf, itype_bosskey);
2407
2/4
✓ Branch 0 taken 1869204 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1869204 times.
1869204 if(itemid > -1 && checkbunny(itemid))
2408 1869204 tile+=itemsbuf[itemid].ltm;
2409 1869204 }
2410
2411
2/2
✓ Branch 0 taken 2644325 times.
✓ Branch 1 taken 2119192 times.
4763517 if(current_item(itype_magiccontainer))
2412 {
2413 2119192 int32_t itemid =
2414
2/2
✓ Branch 0 taken 2025977 times.
✓ Branch 1 taken 93215 times.
2119192 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2415 ? iMagicC
2416 93215 : getHighestLevelEvenUnowned(itemsbuf, itype_magiccontainer);
2417
3/4
✓ Branch 0 taken 2119192 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1870 times.
✓ Branch 3 taken 2117322 times.
2119192 if(itemid > -1 && checkbunny(itemid))
2418 2117322 tile+=itemsbuf[itemid].ltm;
2419 2119192 }
2420
2421
2/2
✓ Branch 0 taken 1308959 times.
✓ Branch 1 taken 3454558 times.
4763517 if(current_item(itype_triforcepiece))
2422 {
2423 3454558 int32_t itemid =
2424
1/2
✓ Branch 0 taken 3454558 times.
✗ Branch 1 not taken.
3454558 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2425 ? iTriforce
2426 : getHighestLevelEvenUnowned(itemsbuf, itype_triforcepiece);
2427
2/4
✓ Branch 0 taken 3454558 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 3454558 times.
3454558 if(itemid > -1 && checkbunny(itemid))
2428 3454558 tile+=itemsbuf[itemid].ltm;
2429 3454558 }
2430
2431
2/2
✓ Branch 0 taken 4763517 times.
✓ Branch 1 taken 2438920704 times.
2443684221 for(int32_t i=0; i<itype_max; i++)
2432 {
2433
2/2
✓ Branch 0 taken 2382618624 times.
✓ Branch 1 taken 56302080 times.
2438920704 if(!get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS))
2434 {
2435
2/2
✓ Branch 0 taken 1099650 times.
✓ Branch 1 taken 55202430 times.
56302080 switch(i)
2436 {
2437 case itype_bomb:
2438 case itype_sbomb:
2439 case itype_clock:
2440 case itype_key:
2441 case itype_lkey:
2442 case itype_map:
2443 case itype_compass:
2444 case itype_bosskey:
2445 case itype_magiccontainer:
2446 case itype_triforcepiece:
2447 1099650 continue; //already handled
2448 }
2449 55202430 }
2450 2437821054 int32_t itemid = current_item_id(i,false);
2451
2/2
✓ Branch 0 taken 2433057537 times.
✓ Branch 1 taken 4763517 times.
2437821054 if(i == itype_shield)
2452 4763517 itemid = getCurrentShield(false);
2453
2454
4/4
✓ Branch 0 taken 67186845 times.
✓ Branch 1 taken 2370634209 times.
✓ Branch 2 taken 100981 times.
✓ Branch 3 taken 67085864 times.
2437821054 if(itemid < 0 || !checkbunny(itemid))
2455 2370735190 continue;
2456
2457 67085864 itemdata const& itm = itemsbuf[itemid];
2458
2459
2/2
✓ Branch 0 taken 62899869 times.
✓ Branch 1 taken 4185995 times.
67085864 switch(itm.family)
2460 {
2461 case itype_shield:
2462
1/2
✓ Branch 0 taken 4185995 times.
✗ Branch 1 not taken.
4185995 if(itm.flags & ITEM_FLAG9) //active shield
2463 {
2464 if(!usingActiveShield(itemid))
2465 {
2466 tile+=itm.misc6; //'Inactive PTM'
2467 continue;
2468 }
2469 }
2470 4185995 break;
2471 }
2472
2473 67085864 tile+=itm.ltm;
2474 67085864 }
2475
2476 4763517 return tile;
2477 }
2478
2479 4763517 int32_t bunny_tile_mod()
2480 {
2481
2/2
✓ Branch 0 taken 1870 times.
✓ Branch 1 taken 4761647 times.
4763517 if(Hero.BunnyClock())
2482 {
2483 1870 return game->get_bunny_ltm();
2484 }
2485 4761647 return 0;
2486 4763517 }
2487
2488 // Hints are drawn on a separate layer to combo reveals.
2489 16332 void draw_lens_under(BITMAP *dest, bool layer)
2490 {
2491 //Lens flag 1: Replacement for qr_LENSHINTS; if set, lens will show hints. Does nothing if flag 2 is set.
2492 //Lens flag 2: Disable "hints", prevent rendering of Secret Combos
2493 //Lens flag 3: Don't show armos/chest/dive items
2494 //Lens flag 4: Show Raft Paths
2495 //Lens flag 5: Show Invisible Enemies
2496
4/4
✓ Branch 0 taken 456 times.
✓ Branch 1 taken 15876 times.
✓ Branch 2 taken 7938 times.
✓ Branch 3 taken 7938 times.
16332 bool hints = (itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2) ? false : (layer && (itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG1));
2497
2498 16332 int32_t strike_hint_table[11]=
2499 {
2500 mfARROW, mfBOMB, mfBRANG, mfWANDMAGIC,
2501 mfSWORD, mfREFMAGIC, mfHOOKSHOT,
2502 mfREFFIREBALL, mfHAMMER, mfSWORDBEAM, mfWAND
2503 };
2504
2505 // int32_t page = tmpscr->cpage;
2506 {
2507 16332 int32_t blink_rate=flash_reduction_enabled()?6:1;
2508 // int32_t temptimer=0;
2509 16332 int32_t tempitem, tempweapon=0;
2510 16332 strike_hint=strike_hint_table[strike_hint_counter];
2511
2512
2/2
✓ Branch 0 taken 15840 times.
✓ Branch 1 taken 492 times.
16332 if(strike_hint_timer>32)
2513 {
2514 492 strike_hint_timer=0;
2515 492 strike_hint_counter=((strike_hint_counter+1)%11);
2516 492 }
2517
2518 16332 ++strike_hint_timer;
2519
2520
2/2
✓ Branch 0 taken 2874432 times.
✓ Branch 1 taken 16332 times.
2890764 for(int32_t i=0; i<176; i++)
2521 {
2522 2874432 int32_t x = (i & 15) << 4;
2523 2874432 int32_t y = (i & 0xF0) + playing_field_offset;
2524 2874432 int32_t tempitemx=-16, tempitemy=-16;
2525 2874432 int32_t tempweaponx=-16, tempweapony=-16;
2526
2527
2/2
✓ Branch 0 taken 5748864 times.
✓ Branch 1 taken 2874432 times.
8623296 for(int32_t iter=0; iter<2; ++iter)
2528 {
2529 5748864 int32_t checkflag=0;
2530
2531
2/2
✓ Branch 0 taken 2874432 times.
✓ Branch 1 taken 2874432 times.
5748864 if(iter==0)
2532 {
2533 2874432 checkflag=combobuf[tmpscr->data[i]].flag;
2534 2874432 }
2535 else
2536 {
2537 2874432 checkflag=tmpscr->sflag[i];
2538 }
2539
2540
2/2
✓ Branch 0 taken 5747766 times.
✓ Branch 1 taken 1098 times.
5748864 if(checkflag==mfSTRIKE)
2541 {
2542
2/2
✓ Branch 0 taken 192 times.
✓ Branch 1 taken 906 times.
1098 if(!hints)
2543 {
2544
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 906 times.
906 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSTRIKE],tmpscr->secretcset[sSTRIKE]);
2545 906 }
2546 else
2547 {
2548 192 checkflag = strike_hint;
2549 }
2550 1098 }
2551
2552
20/36
✓ Branch 0 taken 5706470 times.
✓ Branch 1 taken 3148 times.
✓ Branch 2 taken 3618 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2064 times.
✓ Branch 5 taken 28640 times.
✓ Branch 6 taken 2418 times.
✓ Branch 7 taken 504 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 814 times.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✓ Branch 14 taken 33 times.
✓ Branch 15 taken 96 times.
✓ Branch 16 taken 24 times.
✓ Branch 17 taken 5 times.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✓ Branch 21 taken 16 times.
✓ Branch 22 taken 16 times.
✓ Branch 23 taken 7 times.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✓ Branch 27 taken 16 times.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
✓ Branch 31 taken 17 times.
✓ Branch 32 taken 35 times.
✓ Branch 33 taken 17 times.
✗ Branch 34 not taken.
✓ Branch 35 taken 906 times.
5748864 switch(checkflag)
2553 {
2554 case 0:
2555 case mfZELDA:
2556 case mfPUSHED:
2557 case mfENEMY0:
2558 case mfENEMY1:
2559 case mfENEMY2:
2560 case mfENEMY3:
2561 case mfENEMY4:
2562 case mfENEMY5:
2563 case mfENEMY6:
2564 case mfENEMY7:
2565 case mfENEMY8:
2566 case mfENEMY9:
2567 case mfSINGLE:
2568 case mfSINGLE16:
2569 case mfNOENEMY:
2570 case mfTRAP_H:
2571 case mfTRAP_V:
2572 case mfTRAP_4:
2573 case mfTRAP_LR:
2574 case mfTRAP_UD:
2575 case mfNOGROUNDENEMY:
2576 case mfNOBLOCKS:
2577 case mfSCRIPT1:
2578 case mfSCRIPT2:
2579 case mfSCRIPT3:
2580 case mfSCRIPT4:
2581 case mfSCRIPT5:
2582 case mfSCRIPT6:
2583 case mfSCRIPT7:
2584 case mfSCRIPT8:
2585 case mfSCRIPT9:
2586 case mfSCRIPT10:
2587 case mfSCRIPT11:
2588 case mfSCRIPT12:
2589 case mfSCRIPT13:
2590 case mfSCRIPT14:
2591 case mfSCRIPT15:
2592 case mfSCRIPT16:
2593 case mfSCRIPT17:
2594 case mfSCRIPT18:
2595 case mfSCRIPT19:
2596 case mfSCRIPT20:
2597 case mfPITHOLE:
2598 case mfPITFALLFLOOR:
2599 case mfLAVA:
2600 case mfICE:
2601 case mfICEDAMAGE:
2602 case mfDAMAGE1:
2603 case mfDAMAGE2:
2604 case mfDAMAGE4:
2605 case mfDAMAGE8:
2606 case mfDAMAGE16:
2607 case mfDAMAGE32:
2608 case mfFREEZEALL:
2609 case mfFREZEALLANSFFCS:
2610 case mfFREEZEFFCSOLY:
2611 case mfSCRITPTW1TRIG:
2612 case mfSCRITPTW2TRIG:
2613 case mfSCRITPTW3TRIG:
2614 case mfSCRITPTW4TRIG:
2615 case mfSCRITPTW5TRIG:
2616 case mfSCRITPTW6TRIG:
2617 case mfSCRITPTW7TRIG:
2618 case mfSCRITPTW8TRIG:
2619 case mfSCRITPTW9TRIG:
2620 case mfSCRITPTW10TRIG:
2621 case mfTROWEL:
2622 case mfTROWELNEXT:
2623 case mfTROWELSPECIALITEM:
2624 case mfSLASHPOT:
2625 case mfLIFTPOT:
2626 case mfLIFTORSLASH:
2627 case mfLIFTROCK:
2628 case mfLIFTROCKHEAVY:
2629 case mfDROPITEM:
2630 case mfSPECIALITEM:
2631 case mfDROPKEY:
2632 case mfDROPLKEY:
2633 case mfDROPCOMPASS:
2634 case mfDROPMAP:
2635 case mfDROPBOSSKEY:
2636 case mfSPAWNNPC:
2637 case mfSWITCHHOOK:
2638 case mfSIDEVIEWLADDER:
2639 case mfSIDEVIEWPLATFORM:
2640 case mfNOENEMYSPAWN:
2641 case mfENEMYALL:
2642 case mfNOMIRROR:
2643 case mfUNSAFEGROUND:
2644 case mf168:
2645 case mf169:
2646 case mf170:
2647 case mf171:
2648 case mf172:
2649 case mf173:
2650 case mf174:
2651 case mf175:
2652 case mf176:
2653 case mf177:
2654 case mf178:
2655 case mf179:
2656 case mf180:
2657 case mf181:
2658 case mf182:
2659 case mf183:
2660 case mf184:
2661 case mf185:
2662 case mf186:
2663 case mf187:
2664 case mf188:
2665 case mf189:
2666 case mf190:
2667 case mf191:
2668 case mf192:
2669 case mf193:
2670 case mf194:
2671 case mf195:
2672 case mf196:
2673 case mf197:
2674 case mf198:
2675 case mf199:
2676 case mf200:
2677 case mf201:
2678 case mf202:
2679 case mf203:
2680 case mf204:
2681 case mf205:
2682 case mf206:
2683 case mf207:
2684 case mf208:
2685 case mf209:
2686 case mf210:
2687 case mf211:
2688 case mf212:
2689 case mf213:
2690 case mf214:
2691 case mf215:
2692 case mf216:
2693 case mf217:
2694 case mf218:
2695 case mf219:
2696 case mf220:
2697 case mf221:
2698 case mf222:
2699 case mf223:
2700 case mf224:
2701 case mf225:
2702 case mf226:
2703 case mf227:
2704 case mf228:
2705 case mf229:
2706 case mf230:
2707 case mf231:
2708 case mf232:
2709 case mf233:
2710 case mf234:
2711 case mf235:
2712 case mf236:
2713 case mf237:
2714 case mf238:
2715 case mf239:
2716 case mf240:
2717 case mf241:
2718 case mf242:
2719 case mf243:
2720 case mf244:
2721 case mf245:
2722 case mf246:
2723 case mf247:
2724 case mf248:
2725 case mf249:
2726 case mf250:
2727 case mf251:
2728 case mf252:
2729 case mf253:
2730 case mf254:
2731 case mfEXTENDED:
2732 5706470 break;
2733
2734 case mfPUSHUD:
2735 case mfPUSHLR:
2736 case mfPUSH4:
2737 case mfPUSHU:
2738 case mfPUSHD:
2739 case mfPUSHL:
2740 case mfPUSHR:
2741 case mfPUSHUDNS:
2742 case mfPUSHLRNS:
2743 case mfPUSH4NS:
2744 case mfPUSHUNS:
2745 case mfPUSHDNS:
2746 case mfPUSHLNS:
2747 case mfPUSHRNS:
2748 case mfPUSHUDINS:
2749 case mfPUSHLRINS:
2750 case mfPUSH4INS:
2751 case mfPUSHUINS:
2752 case mfPUSHDINS:
2753 case mfPUSHLINS:
2754 case mfPUSHRINS:
2755
3/4
✓ Branch 0 taken 1829 times.
✓ Branch 1 taken 1319 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1829 times.
3148 if(!hints && ((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&16))
2756
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1829 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1829 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1829 || ((get_debug() && zc_getkey(KEY_N)) && (frame&16))))
2757 {
2758 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->undercombo,tmpscr->undercset);
2759 }
2760
2761
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3148 times.
3148 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2762
3/6
✓ Branch 0 taken 2438 times.
✓ Branch 1 taken 710 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 710 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
3148 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2763 {
2764
2/2
✓ Branch 0 taken 1406 times.
✓ Branch 1 taken 1032 times.
2438 if(hints)
2765 {
2766
3/3
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 63 times.
✓ Branch 2 taken 897 times.
1032 switch(combobuf[tmpscr->data[i]].type)
2767 {
2768 case cPUSH_HEAVY:
2769 case cPUSH_HW:
2770 72 tempitem=getItemIDPower(itemsbuf,itype_bracelet,1);
2771 72 tempitemx=x, tempitemy=y;
2772
2773
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 72 times.
72 if(tempitem>-1)
2774 72 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2775
2776 72 break;
2777
2778 case cPUSH_HEAVY2:
2779 case cPUSH_HW2:
2780 63 tempitem=getItemIDPower(itemsbuf,itype_bracelet,2);
2781 63 tempitemx=x, tempitemy=y;
2782
2783
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 63 times.
63 if(tempitem>-1)
2784 63 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2785
2786 63 break;
2787 }
2788 1032 }
2789 2438 }
2790
2791 3148 break;
2792
2793 case mfWHISTLE:
2794
1/2
✓ Branch 0 taken 2418 times.
✗ Branch 1 not taken.
2418 if(hints)
2795 {
2796 tempitem=getItemID(itemsbuf,itype_whistle,1);
2797
2798 if(tempitem<0) break;
2799
2800 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2801 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2802 {
2803 tempitemx=x;
2804 tempitemy=y;
2805 }
2806
2807 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2808 }
2809
2810 2418 break;
2811
2812 //Why is this here?
2813 case mfFAIRY:
2814 case mfMAGICFAIRY:
2815 case mfALLFAIRY:
2816 if(hints)
2817 {
2818 tempitem=getItemID(itemsbuf, itype_fairy,1);//iFairyMoving;
2819
2820 if(tempitem < 0) break;
2821
2822 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2823 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2824 {
2825 tempitemx=x;
2826 tempitemy=y;
2827 }
2828
2829 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2830 }
2831
2832 break;
2833
2834 case mfANYFIRE:
2835
2/2
✓ Branch 0 taken 252 times.
✓ Branch 1 taken 252 times.
504 if(!hints)
2836 {
2837
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 252 times.
252 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sBCANDLE],tmpscr->secretcset[sBCANDLE]);
2838 252 }
2839 else
2840 {
2841 252 tempitem=getItemID(itemsbuf,itype_candle,1);
2842
2843
1/2
✓ Branch 0 taken 252 times.
✗ Branch 1 not taken.
252 if(tempitem<0) break;
2844
2845
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 252 times.
252 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2846
3/6
✓ Branch 0 taken 189 times.
✓ Branch 1 taken 63 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 63 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
252 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2847 {
2848 189 tempitemx=x;
2849 189 tempitemy=y;
2850 189 }
2851
2852 252 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2853 }
2854
2855 504 break;
2856
2857 case mfSTRONGFIRE:
2858 if(!hints)
2859 {
2860 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sRCANDLE],tmpscr->secretcset[sRCANDLE]);
2861 }
2862 else
2863 {
2864 tempitem=getItemID(itemsbuf,itype_candle,2);
2865
2866 if(tempitem<0) break;
2867
2868 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2869 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2870 {
2871 tempitemx=x;
2872 tempitemy=y;
2873 }
2874
2875 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2876 }
2877
2878 break;
2879
2880 case mfMAGICFIRE:
2881 if(!hints)
2882 {
2883 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sWANDFIRE],tmpscr->secretcset[sWANDFIRE]);
2884 }
2885 else
2886 {
2887 tempitem=getItemID(itemsbuf,itype_wand,1);
2888
2889 if(tempitem<0) break;
2890
2891 tempweapon=wFire;
2892
2893 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2894 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2895 {
2896 tempitemx=x;
2897 tempitemy=y;
2898 }
2899 else
2900 {
2901 tempweaponx=x;
2902 tempweapony=y;
2903 }
2904
2905 putweapon(dest,tempweaponx,tempweapony,tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
2906 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2907 }
2908
2909 break;
2910
2911 case mfDIVINEFIRE:
2912 if(!hints)
2913 {
2914 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sDIVINEFIRE],tmpscr->secretcset[sDIVINEFIRE]);
2915 }
2916 else
2917 {
2918 tempitem=getItemID(itemsbuf,itype_divinefire,1);
2919
2920 if(tempitem<0) break;
2921
2922 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2923 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2924 {
2925 tempitemx=x;
2926 tempitemy=y;
2927 }
2928
2929 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2930 }
2931
2932 break;
2933
2934 case mfARROW:
2935
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 732 times.
814 if(!hints)
2936 {
2937
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 732 times.
732 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sARROW],tmpscr->secretcset[sARROW]);
2938 732 }
2939 else
2940 {
2941 82 tempitem=getItemID(itemsbuf,itype_arrow,1);
2942
2943
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 if(tempitem<0) break;
2944
2945
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 82 times.
82 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2946
3/6
✓ Branch 0 taken 61 times.
✓ Branch 1 taken 21 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 21 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
82 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2947 {
2948 61 tempitemx=x;
2949 61 tempitemy=y;
2950 61 }
2951
2952 82 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2953 }
2954
2955 814 break;
2956
2957 case mfSARROW:
2958 if(!hints)
2959 {
2960 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSARROW],tmpscr->secretcset[sSARROW]);
2961 }
2962 else
2963 {
2964 tempitem=getItemID(itemsbuf,itype_arrow,2);
2965
2966 if(tempitem<0) break;
2967
2968 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2969 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2970 {
2971 tempitemx=x;
2972 tempitemy=y;
2973 }
2974
2975 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2976 }
2977
2978 break;
2979
2980 case mfGARROW:
2981 if(!hints)
2982 {
2983 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sGARROW],tmpscr->secretcset[sGARROW]);
2984 }
2985 else
2986 {
2987 tempitem=getItemID(itemsbuf,itype_arrow,3);
2988
2989 if(tempitem<0) break;
2990
2991 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2992 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2993 {
2994 tempitemx=x;
2995 tempitemy=y;
2996 }
2997
2998 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2999 }
3000
3001 break;
3002
3003 case mfBOMB:
3004
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 16 times.
33 if(!hints)
3005 {
3006
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sBOMB],tmpscr->secretcset[sBOMB]);
3007 16 }
3008 else
3009 {
3010 //tempitem=getItemID(itemsbuf,itype_bomb,1);
3011 17 tempweapon = wLitBomb;
3012
3013 //if (tempitem<0) break;
3014
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3015
3/6
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
17 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3016 {
3017 12 tempweaponx=x;
3018 12 tempweapony=y;
3019 12 }
3020
3021 17 putweapon(dest,tempweaponx,tempweapony+lens_hint_weapon[tempweapon][4],tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
3022 }
3023
3024 33 break;
3025
3026 case mfSBOMB:
3027
2/2
✓ Branch 0 taken 48 times.
✓ Branch 1 taken 48 times.
96 if(!hints)
3028 {
3029
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
48 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSBOMB],tmpscr->secretcset[sSBOMB]);
3030 48 }
3031 else
3032 {
3033 //tempitem=getItemID(itemsbuf,itype_sbomb,1);
3034 //if (tempitem<0) break;
3035 48 tempweapon = wLitSBomb;
3036
3037
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
48 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3038
3/6
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 12 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
48 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3039 {
3040 36 tempweaponx=x;
3041 36 tempweapony=y;
3042 36 }
3043
3044 48 putweapon(dest,tempweaponx,tempweapony+lens_hint_weapon[tempweapon][4],tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
3045 }
3046
3047 96 break;
3048
3049 case mfARMOS_SECRET:
3050
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 12 times.
24 if(!hints)
3051 {
3052
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSTAIRS],tmpscr->secretcset[sSTAIRS]);
3053 12 }
3054 24 break;
3055
3056 case mfBRANG:
3057
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if(!hints)
3058 {
3059 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sBRANG],tmpscr->secretcset[sBRANG]);
3060 }
3061 else
3062 {
3063 5 tempitem=getItemID(itemsbuf,itype_brang,1);
3064
3065
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if(tempitem<0) break;
3066
3067
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
5 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3068
3/6
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
5 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3069 {
3070 4 tempitemx=x;
3071 4 tempitemy=y;
3072 4 }
3073
3074 5 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3075 }
3076
3077 5 break;
3078
3079 case mfMBRANG:
3080 if(!hints)
3081 {
3082 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sMBRANG],tmpscr->secretcset[sMBRANG]);
3083 }
3084 else
3085 {
3086 tempitem=getItemID(itemsbuf,itype_brang,2);
3087
3088 if(tempitem<0) break;
3089
3090 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3091 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3092 {
3093 tempitemx=x;
3094 tempitemy=y;
3095 }
3096
3097 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3098 }
3099
3100 break;
3101
3102 case mfFBRANG:
3103 if(!hints)
3104 {
3105 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sFBRANG],tmpscr->secretcset[sFBRANG]);
3106 }
3107 else
3108 {
3109 tempitem=getItemID(itemsbuf,itype_brang,3);
3110
3111 if(tempitem<0) break;
3112
3113 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3114 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3115 {
3116 tempitemx=x;
3117 tempitemy=y;
3118 }
3119
3120 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3121 }
3122
3123 break;
3124
3125 case mfWANDMAGIC:
3126 if(!hints)
3127 {
3128 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sWANDMAGIC],tmpscr->secretcset[sWANDMAGIC]);
3129 }
3130 else
3131 {
3132 tempitem=getItemID(itemsbuf,itype_wand,1);
3133
3134 if(tempitem<0) break;
3135
3136 tempweapon=itemsbuf[tempitem].wpn3;
3137
3138 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3139 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3140 {
3141 tempitemx=x;
3142 tempitemy=y;
3143 }
3144 else
3145 {
3146 tempweaponx=x;
3147 tempweapony=y;
3148 --lens_hint_weapon[wMagic][4];
3149
3150 if(lens_hint_weapon[wMagic][4]<-8)
3151 {
3152 lens_hint_weapon[wMagic][4]=8;
3153 }
3154 }
3155
3156 putweapon(dest,tempweaponx,tempweapony+lens_hint_weapon[tempweapon][4],tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
3157 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3158 }
3159
3160 break;
3161
3162 case mfREFMAGIC:
3163
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!hints)
3164 {
3165 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sREFMAGIC],tmpscr->secretcset[sREFMAGIC]);
3166 }
3167 else
3168 {
3169 16 tempitem=getItemID(itemsbuf,itype_shield,3);
3170
3171
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(tempitem<0) break;
3172
3173 16 tempweapon=ewMagic;
3174
3175
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3176
3/6
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
16 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3177 {
3178 13 tempitemx=x;
3179 13 tempitemy=y;
3180 13 }
3181 else
3182 {
3183 3 tempweaponx=x;
3184 3 tempweapony=y;
3185
3186
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 1 times.
3 if(lens_hint_weapon[ewMagic][2]==up)
3187 {
3188 1 --lens_hint_weapon[ewMagic][4];
3189 1 }
3190 else
3191 {
3192 2 ++lens_hint_weapon[ewMagic][4];
3193 }
3194
3195
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(lens_hint_weapon[ewMagic][4]>8)
3196 {
3197 lens_hint_weapon[ewMagic][2]=up;
3198 }
3199
3200
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 2 times.
3 if(lens_hint_weapon[ewMagic][4]<=0)
3201 {
3202 2 lens_hint_weapon[ewMagic][2]=down;
3203 2 }
3204 }
3205
3206 16 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3207 16 putweapon(dest,tempweaponx,tempweapony+lens_hint_weapon[tempweapon][4],tempweapon, 0, lens_hint_weapon[ewMagic][2], lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
3208 }
3209
3210 16 break;
3211
3212 case mfREFFIREBALL:
3213
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!hints)
3214 {
3215 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sREFFIREBALL],tmpscr->secretcset[sREFFIREBALL]);
3216 }
3217 else
3218 {
3219 16 tempitem=getItemID(itemsbuf,itype_shield,3);
3220
3221
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(tempitem<0) break;
3222
3223 16 tempweapon=ewFireball;
3224
3225
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3226
3/6
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
16 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3227 {
3228 12 tempitemx=x;
3229 12 tempitemy=y;
3230 12 tempweaponx=x;
3231 12 tempweapony=y;
3232 12 ++lens_hint_weapon[ewFireball][3];
3233
3234
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 1 times.
12 if(lens_hint_weapon[ewFireball][3]>8)
3235 {
3236 1 lens_hint_weapon[ewFireball][3]=-8;
3237 1 lens_hint_weapon[ewFireball][4]=8;
3238 1 }
3239
3240
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 4 times.
12 if(lens_hint_weapon[ewFireball][3]>0)
3241 {
3242 8 ++lens_hint_weapon[ewFireball][4];
3243 8 }
3244 else
3245 {
3246 4 --lens_hint_weapon[ewFireball][4];
3247 }
3248 12 }
3249
3250 16 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3251 16 putweapon(dest,tempweaponx+lens_hint_weapon[tempweapon][3],tempweapony+lens_hint_weapon[ewFireball][4],tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
3252 }
3253
3254 16 break;
3255
3256 case mfSWORD:
3257
1/2
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
7 if(!hints)
3258 {
3259 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSWORD],tmpscr->secretcset[sSWORD]);
3260 }
3261 else
3262 {
3263 7 tempitem=getItemID(itemsbuf,itype_sword,1);
3264
3265
1/2
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
7 if(tempitem<0) break;
3266
3267
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
7 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3268
3/6
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
7 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3269 {
3270 5 tempitemx=x;
3271 5 tempitemy=y;
3272 5 }
3273
3274 7 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3275 }
3276
3277 7 break;
3278
3279 case mfWSWORD:
3280 if(!hints)
3281 {
3282 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sWSWORD],tmpscr->secretcset[sWSWORD]);
3283 }
3284 else
3285 {
3286 tempitem=getItemID(itemsbuf,itype_sword,2);
3287
3288 if(tempitem<0) break;
3289
3290 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3291 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3292 {
3293 tempitemx=x;
3294 tempitemy=y;
3295 }
3296
3297 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3298 }
3299
3300 break;
3301
3302 case mfMSWORD:
3303 if(!hints)
3304 {
3305 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sMSWORD],tmpscr->secretcset[sMSWORD]);
3306 }
3307 else
3308 {
3309 tempitem=getItemID(itemsbuf,itype_sword,3);
3310
3311 if(tempitem<0) break;
3312
3313 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3314 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3315 {
3316 tempitemx=x;
3317 tempitemy=y;
3318 }
3319
3320 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3321 }
3322
3323 break;
3324
3325 case mfXSWORD:
3326 if(!hints)
3327 {
3328 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sXSWORD],tmpscr->secretcset[sXSWORD]);
3329 }
3330 else
3331 {
3332 tempitem=getItemID(itemsbuf,itype_sword,4);
3333
3334 if(tempitem<0) break;
3335
3336 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3337 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3338 {
3339 tempitemx=x;
3340 tempitemy=y;
3341 }
3342
3343 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3344 }
3345
3346 break;
3347
3348 case mfSWORDBEAM:
3349
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!hints)
3350 {
3351 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSWORDBEAM],tmpscr->secretcset[sSWORDBEAM]);
3352 }
3353 else
3354 {
3355 16 tempitem=getItemID(itemsbuf,itype_sword,1);
3356
3357
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(tempitem<0) break;
3358
3359
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3360
3/6
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
16 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3361 {
3362 11 tempitemx=x;
3363 11 tempitemy=y;
3364 11 }
3365
3366 16 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 1);
3367 }
3368
3369 16 break;
3370
3371 case mfWSWORDBEAM:
3372 if(!hints)
3373 {
3374 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sWSWORDBEAM],tmpscr->secretcset[sWSWORDBEAM]);
3375 }
3376 else
3377 {
3378 tempitem=getItemID(itemsbuf,itype_sword,2);
3379
3380 if(tempitem<0) break;
3381
3382 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3383 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3384 {
3385 tempitemx=x;
3386 tempitemy=y;
3387 }
3388
3389 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 2);
3390 }
3391
3392 break;
3393
3394 case mfMSWORDBEAM:
3395 if(!hints)
3396 {
3397 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sMSWORDBEAM],tmpscr->secretcset[sMSWORDBEAM]);
3398 }
3399 else
3400 {
3401 tempitem=getItemID(itemsbuf,itype_sword,3);
3402
3403 if(tempitem<0) break;
3404
3405 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3406 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3407 {
3408 tempitemx=x;
3409 tempitemy=y;
3410 }
3411
3412 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 3);
3413 }
3414
3415 break;
3416
3417 case mfXSWORDBEAM:
3418 if(!hints)
3419 {
3420 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sXSWORDBEAM],tmpscr->secretcset[sXSWORDBEAM]);
3421 }
3422 else
3423 {
3424 tempitem=getItemID(itemsbuf,itype_sword,4);
3425
3426 if(tempitem<0) break;
3427
3428 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3429 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3430 {
3431 tempitemx=x;
3432 tempitemy=y;
3433 }
3434
3435 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 4);
3436 }
3437
3438 break;
3439
3440 case mfHOOKSHOT:
3441
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!hints)
3442 {
3443 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sHOOKSHOT],tmpscr->secretcset[sHOOKSHOT]);
3444 }
3445 else
3446 {
3447 17 tempitem=getItemID(itemsbuf,itype_hookshot,1);
3448
3449
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(tempitem<0) break;
3450
3451
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3452
3/6
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
17 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3453 {
3454 12 tempitemx=x;
3455 12 tempitemy=y;
3456 12 }
3457
3458 17 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3459 }
3460
3461 17 break;
3462
3463 case mfWAND:
3464
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if(!hints)
3465 {
3466 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sWAND],tmpscr->secretcset[sWAND]);
3467 }
3468 else
3469 {
3470 35 tempitem=getItemID(itemsbuf,itype_wand,1);
3471
3472
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if(tempitem<0) break;
3473
3474
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35 times.
35 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3475
3/6
✓ Branch 0 taken 28 times.
✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
35 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3476 {
3477 28 tempitemx=x;
3478 28 tempitemy=y;
3479 28 }
3480
3481 35 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3482 }
3483
3484 35 break;
3485
3486 case mfHAMMER:
3487
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!hints)
3488 {
3489 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sHAMMER],tmpscr->secretcset[sHAMMER]);
3490 }
3491 else
3492 {
3493 17 tempitem=getItemID(itemsbuf,itype_hammer,1);
3494
3495
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(tempitem<0) break;
3496
3497
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3498
3/6
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
17 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3499 {
3500 13 tempitemx=x;
3501 13 tempitemy=y;
3502 13 }
3503
3504 17 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3505 }
3506
3507 17 break;
3508
3509 case mfARMOS_ITEM:
3510 case mfDIVE_ITEM:
3511
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2064 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2064 times.
2064 if((!getmapflag() || (tmpscr->flags9&fBELOWRETURN)) && !(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG3))
3512 {
3513 2064 putitem2(dest,x,y,tmpscr->catchall, lens_hint_item[tmpscr->catchall][0], lens_hint_item[tmpscr->catchall][1], 0);
3514 2064 }
3515 2064 break;
3516
3517 case 16:
3518 case 17:
3519 case 18:
3520 case 19:
3521 case 20:
3522 case 21:
3523 case 22:
3524 case 23:
3525 case 24:
3526 case 25:
3527 case 26:
3528 case 27:
3529 case 28:
3530 case 29:
3531 case 30:
3532 case 31:
3533
2/2
✓ Branch 0 taken 1008 times.
✓ Branch 1 taken 2610 times.
3618 if(!hints)
3534
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2610 times.
5220 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))
3535 2610 putcombo(dest,x,y,tmpscr->secretcombo[checkflag-16+4],tmpscr->secretcset[checkflag-16+4]);
3536
3537 3618 break;
3538 case mfSECRETSNEXT:
3539 if(!hints)
3540 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))
3541 putcombo(dest,x,y,tmpscr->data[i]+1,tmpscr->cset[i]);
3542
3543 break;
3544
3545 case mfSTRIKE:
3546
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 906 times.
906 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))
3547 {
3548 906 goto special;
3549 }
3550 else
3551 {
3552 break;
3553 }
3554
3555 28640 default: goto special;
3556
3557 special:
3558
8/8
✓ Branch 0 taken 14677 times.
✓ Branch 1 taken 14869 times.
✓ Branch 2 taken 473 times.
✓ Branch 3 taken 14204 times.
✓ Branch 4 taken 441 times.
✓ Branch 5 taken 32 times.
✓ Branch 6 taken 6108 times.
✓ Branch 7 taken 8128 times.
29546 if(layer && ((checkflag!=mfRAFT && checkflag!=mfRAFT_BRANCH&& checkflag!=mfRAFT_BOUNCE) ||(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG4)))
3559 {
3560
4/8
✗ Branch 0 not taken.
✓ Branch 1 taken 6549 times.
✓ Branch 2 taken 4913 times.
✓ Branch 3 taken 1636 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1636 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
6549 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate)) || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3561 {
3562 4913 rectfill(dest,x,y,x+15,y+15,WHITE);
3563 4913 }
3564 6549 }
3565
3566 29546 break;
3567 }
3568 5748864 }
3569 2874432 }
3570
3571
2/2
✓ Branch 0 taken 8166 times.
✓ Branch 1 taken 8166 times.
16332 if(layer)
3572 {
3573
2/2
✓ Branch 0 taken 7978 times.
✓ Branch 1 taken 188 times.
8166 if(tmpscr->door[0]==dWALK)
3574 188 rectfill(dest, 120, 16+playing_field_offset, 135, 31+playing_field_offset, WHITE);
3575
3576
2/2
✓ Branch 0 taken 7969 times.
✓ Branch 1 taken 197 times.
8166 if(tmpscr->door[1]==dWALK)
3577 197 rectfill(dest, 120, 144+playing_field_offset, 135, 159+playing_field_offset, WHITE);
3578
3579
2/2
✓ Branch 0 taken 8014 times.
✓ Branch 1 taken 152 times.
8166 if(tmpscr->door[2]==dWALK)
3580 152 rectfill(dest, 16, 80+playing_field_offset, 31, 95+playing_field_offset, WHITE);
3581
3582
2/2
✓ Branch 0 taken 7940 times.
✓ Branch 1 taken 226 times.
8166 if(tmpscr->door[3]==dWALK)
3583 226 rectfill(dest, 224, 80+playing_field_offset, 239, 95+playing_field_offset, WHITE);
3584
3585
2/2
✓ Branch 0 taken 8123 times.
✓ Branch 1 taken 43 times.
8166 if(tmpscr->door[0]==dBOMB)
3586 {
3587 43 showbombeddoor(dest, 0);
3588 43 }
3589
3590
2/2
✓ Branch 0 taken 8127 times.
✓ Branch 1 taken 39 times.
8166 if(tmpscr->door[1]==dBOMB)
3591 {
3592 39 showbombeddoor(dest, 1);
3593 39 }
3594
3595
1/2
✓ Branch 0 taken 8166 times.
✗ Branch 1 not taken.
8166 if(tmpscr->door[2]==dBOMB)
3596 {
3597 showbombeddoor(dest, 2);
3598 }
3599
3600
2/2
✓ Branch 0 taken 8129 times.
✓ Branch 1 taken 37 times.
8166 if(tmpscr->door[3]==dBOMB)
3601 {
3602 37 showbombeddoor(dest, 3);
3603 37 }
3604 8166 }
3605
3606
2/2
✓ Branch 0 taken 14298 times.
✓ Branch 1 taken 2034 times.
16332 if(tmpscr->stairx + tmpscr->stairy)
3607 {
3608
2/2
✓ Branch 0 taken 911 times.
✓ Branch 1 taken 1123 times.
2034 if(!hints)
3609 {
3610
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1123 times.
1123 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))
3611 1123 putcombo(dest,tmpscr->stairx,tmpscr->stairy+playing_field_offset,tmpscr->secretcombo[sSTAIRS],tmpscr->secretcset[sSTAIRS]);
3612 1123 }
3613 else
3614 {
3615
2/2
✓ Branch 0 taken 863 times.
✓ Branch 1 taken 48 times.
911 if(tmpscr->flags&fWHISTLE)
3616 {
3617 48 tempitem=getItemID(itemsbuf,itype_whistle,1);
3618 48 int32_t tempitemx=-16;
3619 48 int32_t tempitemy=-16;
3620
3621
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
48 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&(blink_rate/4)))
3622
3/6
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 24 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 24 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
48 || ((get_debug() && zc_getkey(KEY_N)) && (frame&(blink_rate/4))))
3623 {
3624 24 tempitemx=tmpscr->stairx;
3625 24 tempitemy=tmpscr->stairy+playing_field_offset;
3626 24 }
3627
3628 48 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3629 48 }
3630 }
3631 2034 }
3632 }
3633 16332 }
3634
3635 BITMAP *lens_scr_d; // The "d" is for "destructible"!
3636
3637 7997 void draw_lens_over()
3638 {
3639 // Oh, what the heck.
3640 static BITMAP *lens_scr = NULL;
3641 static int32_t last_width = -1;
3642 7997 int32_t width = itemsbuf[current_item_id(itype_lens,true)].misc1;
3643
3644 // Only redraw the circle if the size has changed
3645
2/2
✓ Branch 0 taken 7992 times.
✓ Branch 1 taken 5 times.
7997 if(width != last_width)
3646 {
3647
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if(lens_scr == NULL)
3648 {
3649 5 lens_scr = create_bitmap_ex(8,2*288,2*(240-playing_field_offset));
3650 5 }
3651
3652 5 clear_to_color(lens_scr, BLACK);
3653 5 circlefill(lens_scr, 288, 240-playing_field_offset, width, 0);
3654 5 circle(lens_scr, 288, 240-playing_field_offset, width+2, 0);
3655 5 circle(lens_scr, 288, 240-playing_field_offset, width+5, 0);
3656 5 last_width=width;
3657 5 }
3658
3659 7997 masked_blit(lens_scr, framebuf, 288-(HeroX()+8), 240-playing_field_offset-(HeroY()+8), 0, playing_field_offset, 256, 168);
3660 7997 }
3661
3662 //----------------------------------------------------------------
3663
3664 30701 void draw_wavy(BITMAP *source, BITMAP *target, int32_t amplitude, bool interpol)
3665 {
3666 //recreating a big bitmap every frame is highly sluggish.
3667
4/6
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 30699 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
30701 static BITMAP *wavebuf = create_bitmap_ex(8,288,240-original_playing_field_offset);
3668 30701 clear_to_color(wavebuf, BLACK);
3669 30701 blit(source,wavebuf,0,original_playing_field_offset,16,0,256,224-original_playing_field_offset);
3670
3671 int32_t ofs;
3672 // int32_t amplitude=8;
3673 // int32_t wavelength=4;
3674
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30701 times.
30701 amplitude = zc_min(2048,amplitude); // some arbitrary limit to prevent crashing
3675
3/6
✓ Branch 0 taken 30701 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 30701 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 30701 times.
30701 if(flash_reduction_enabled() && !get_bit(quest_rules, qr_WAVY_NO_EPILEPSY)) amplitude = zc_min(16,amplitude);
3676 30701 int32_t amp2=168;
3677
2/4
✓ Branch 0 taken 30701 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 30701 times.
30701 if(flash_reduction_enabled() && !get_bit(quest_rules, qr_WAVY_NO_EPILEPSY_2)) amp2*=2;
3678 30701 int32_t i=frame%amp2;
3679
3680
2/2
✓ Branch 0 taken 5157768 times.
✓ Branch 1 taken 30701 times.
5188469 for(int32_t j=0; j<168; j++)
3681 {
3682
3/4
✓ Branch 0 taken 2578884 times.
✓ Branch 1 taken 2578884 times.
✓ Branch 2 taken 2578884 times.
✗ Branch 3 not taken.
5157768 if(j&1 && interpol)
3683 {
3684 // Add 288*2048 to ensure it's never negative. It'll get modded out.
3685 ofs=288*2048+int32_t(zc::math::Sin((double(i+j)*2*PI/amp2))*amplitude);
3686 }
3687 else
3688 {
3689 5157768 ofs=288*2048-int32_t(zc::math::Sin((double(i+j)*2*PI/amp2))*amplitude);
3690 }
3691
3692
1/2
✓ Branch 0 taken 5157768 times.
✗ Branch 1 not taken.
5157768 if(ofs)
3693 {
3694
2/2
✓ Branch 0 taken 1320388608 times.
✓ Branch 1 taken 5157768 times.
1325546376 for(int32_t k=0; k<256; k++)
3695 {
3696 1320388608 target->line[j+original_playing_field_offset][k]=wavebuf->line[j][(k+ofs+16)%288];
3697 1320388608 }
3698 5157768 }
3699 5157768 }
3700 30701 }
3701
3702 3312 void draw_fuzzy(int32_t fuzz)
3703 // draws from right half of scrollbuf to framebuf
3704 {
3705 int32_t firstx, firsty, xstep, ystep, i, y, dx, dy;
3706 byte *start, *si, *di;
3707
3708
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3312 times.
3312 if(fuzz<1)
3709 fuzz = 1;
3710
3711 3312 xstep = 128%fuzz;
3712
3713
2/2
✓ Branch 0 taken 690 times.
✓ Branch 1 taken 2622 times.
3312 if(xstep > 0)
3714 2622 xstep = fuzz-xstep;
3715
3716 3312 ystep = 112%fuzz;
3717
3718
2/2
✓ Branch 0 taken 966 times.
✓ Branch 1 taken 2346 times.
3312 if(ystep > 0)
3719 2346 ystep = fuzz-ystep;
3720
3721 3312 firsty = 1;
3722
3723
2/2
✓ Branch 0 taken 3312 times.
✓ Branch 1 taken 119508 times.
122820 for(y=0; y<224;)
3724 {
3725 119508 start = &(scrollbuf->line[y][256]);
3726
3727
4/4
✓ Branch 0 taken 117852 times.
✓ Branch 1 taken 743544 times.
✓ Branch 2 taken 741888 times.
✓ Branch 3 taken 119508 times.
861396 for(dy=0; dy<ystep && dy+y<224; dy++)
3728 {
3729 741888 si = start;
3730 741888 di = &(framebuf->line[y+dy][0]);
3731 741888 i = xstep;
3732 741888 firstx = 1;
3733
3734
2/2
✓ Branch 0 taken 189923328 times.
✓ Branch 1 taken 741888 times.
190665216 for(dx=0; dx<256; dx++)
3735 {
3736 189923328 *(di++) = *si;
3737
3738
2/2
✓ Branch 0 taken 160031424 times.
✓ Branch 1 taken 29891904 times.
189923328 if(++i >= fuzz)
3739 {
3740
2/2
✓ Branch 0 taken 29150016 times.
✓ Branch 1 taken 741888 times.
29891904 if(!firstx)
3741 29150016 si += fuzz;
3742 else
3743 {
3744 741888 si += fuzz-xstep;
3745 741888 firstx = 0;
3746 }
3747
3748 29891904 i = 0;
3749 29891904 }
3750 189923328 }
3751 741888 }
3752
3753
2/2
✓ Branch 0 taken 116196 times.
✓ Branch 1 taken 3312 times.
119508 if(!firsty)
3754 116196 y += fuzz;
3755 else
3756 {
3757 3312 y += ystep;
3758 3312 ystep = fuzz;
3759 3312 firsty = 0;
3760 }
3761 }
3762 3312 }
3763
3764 7521922 void updatescr(bool allowwavy)
3765 {
3766
4/6
✓ Branch 0 taken 31 times.
✓ Branch 1 taken 7521891 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 31 times.
✓ Branch 4 taken 31 times.
✗ Branch 5 not taken.
7521922 static BITMAP *wavybuf = create_bitmap_ex(8,256,224);
3767
4/6
✓ Branch 0 taken 31 times.
✓ Branch 1 taken 7521891 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 31 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 31 times.
7521922 static BITMAP *panorama = create_bitmap_ex(8,256,224);
3768
3769
2/2
✓ Branch 0 taken 7496218 times.
✓ Branch 1 taken 25704 times.
7521922 if(toogam)
3770 {
3771 25704 textout_ex(framebuf,font,"no walls",8,216,1,-1);
3772 25704 }
3773
3774
1/2
✓ Branch 0 taken 7521922 times.
✗ Branch 1 not taken.
7521922 if(Showpal)
3775 dump_pal(framebuf);
3776
3777
2/2
✓ Branch 0 taken 7427458 times.
✓ Branch 1 taken 94464 times.
7521922 if(!Playing)
3778 94464 black_opening_count=0;
3779
3780
2/2
✓ Branch 0 taken 7475524 times.
✓ Branch 1 taken 46398 times.
7521922 if(black_opening_count<0) //shape is opening up
3781 {
3782 46398 black_opening(framebuf,black_opening_x,black_opening_y,(66+black_opening_count),66);
3783
3784
2/4
✓ Branch 0 taken 46398 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 46398 times.
46398 if(Advance||(!Paused))
3785 {
3786 46398 ++black_opening_count;
3787 46398 }
3788 46398 }
3789
2/2
✓ Branch 0 taken 7457308 times.
✓ Branch 1 taken 18216 times.
7475524 else if(black_opening_count>0) //shape is closing
3790 {
3791 18216 black_opening(framebuf,black_opening_x,black_opening_y,black_opening_count,66);
3792
3793
2/4
✓ Branch 0 taken 18216 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 18216 times.
18216 if(Advance||(!Paused))
3794 {
3795 18216 --black_opening_count;
3796 18216 }
3797 18216 }
3798
3799
3/4
✓ Branch 0 taken 7458287 times.
✓ Branch 1 taken 63635 times.
✓ Branch 2 taken 7458287 times.
✗ Branch 3 not taken.
7521922 if(black_opening_count==0&&black_opening_shape==bosFADEBLACK)
3800 {
3801 black_opening_shape = bosCIRCLE;
3802 memcpy(RAMpal, tempblackpal, PAL_SIZE*sizeof(RGB));
3803 refreshTints();
3804 refreshpal=true;
3805 }
3806
3807
2/2
✓ Branch 0 taken 7306228 times.
✓ Branch 1 taken 215694 times.
7521922 if(refreshpal)
3808 {
3809 215694 refreshpal=false;
3810 215694 RAMpal[253] = _RGB(0,0,0);
3811 215694 RAMpal[254] = _RGB(63,63,63);
3812 215694 hw_palette = &RAMpal;
3813 215694 update_hw_pal = true;
3814
3815 215694 create_rgb_table(&rgb_table, RAMpal, NULL);
3816 215694 create_zc_trans_table(&trans_table, RAMpal, 128, 128, 128);
3817 215694 memcpy(&trans_table2, &trans_table, sizeof(COLOR_MAP));
3818
3819
2/2
✓ Branch 0 taken 55217664 times.
✓ Branch 1 taken 215694 times.
55433358 for(int32_t q=0; q<PAL_SIZE; q++)
3820 {
3821 55217664 trans_table2.data[0][q] = q;
3822 55217664 trans_table2.data[q][q] = q;
3823 55217664 }
3824 215694 }
3825
3826 7521922 bool clearwavy = (wavy <= 0);
3827
3828
2/2
✓ Branch 0 taken 7245 times.
✓ Branch 1 taken 7514677 times.
7521922 if(wavy <= 0)
3829 {
3830 // So far one thing can alter wavy apart from scripts: Wavy DMaps.
3831 7514677 wavy = (DMaps[currdmap].flags&dmfWAVY ? 4 : 0);
3832 7514677 }
3833
3834 7521922 blit(framebuf, wavybuf, 0, 0, 0, 0, 256, 224);
3835
3836
6/6
✓ Branch 0 taken 30951 times.
✓ Branch 1 taken 7490971 times.
✓ Branch 2 taken 30829 times.
✓ Branch 3 taken 122 times.
✓ Branch 4 taken 128 times.
✓ Branch 5 taken 30701 times.
7521922 if(wavy && Playing && allowwavy)
3837 {
3838 30701 draw_wavy(framebuf, wavybuf, wavy,false);
3839 30701 }
3840
3841
2/2
✓ Branch 0 taken 7514677 times.
✓ Branch 1 taken 7245 times.
7521922 if(clearwavy)
3842 7514677 wavy = 0; // Wavy was set by a DMap flag. Clear it.
3843
2/4
✓ Branch 0 taken 7245 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 7245 times.
7245 else if(Playing && !Paused)
3844 7245 wavy--; // Wavy was set by a script. Decrement it.
3845
3846
5/6
✓ Branch 0 taken 7427458 times.
✓ Branch 1 taken 94464 times.
✓ Branch 2 taken 170662 times.
✓ Branch 3 taken 7256796 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 170662 times.
7521922 if(Playing && msgpos && !screenscrolling)
3847 {
3848
1/2
✓ Branch 0 taken 170662 times.
✗ Branch 1 not taken.
170662 if(!(msg_bg_display_buf->clip))
3849 170662 blit_msgstr_bg(framebuf,0,0,0,playing_field_offset,256,168);
3850
1/2
✓ Branch 0 taken 170662 times.
✗ Branch 1 not taken.
170662 if(!(msg_portrait_display_buf->clip))
3851 170662 blit_msgstr_prt(framebuf,0,0,0,playing_field_offset,256,168);
3852
1/2
✓ Branch 0 taken 170662 times.
✗ Branch 1 not taken.
170662 if(!(msg_txt_display_buf->clip))
3853 170662 blit_msgstr_fg(framebuf,0,0,0,playing_field_offset,256,168);
3854 170662 }
3855
3856 /*
3857 if(!(msg_txt_display_buf->clip) && Playing && msgpos && !screenscrolling)
3858 {
3859 BITMAP* subBmp = 0;
3860 masked_blit(msg_txt_display_buf,subBmp,0,0,0,playing_field_offset,256,168);
3861 // masked_blit(msg_txt_display_buf,subBmp,0,playing_field_offset,256,168);
3862 draw_trans_sprite(framebuf, subBmp, 0, playing_field_offset);
3863 destroy_bitmap(subBmp);
3864 //void draw_sprite_ex(BITMAP *bmp, BITMAP *sprite, int32_t x, int32_t y, int32_t mode, int32_t flip);
3865 // masked_blit(msg_txt_display_buf,framebuf,0,0,0,playing_field_offset,256,168);
3866 //void masked_blit(BITMAP *source, BITMAP *dest, int32_t source_x, int32_t source_y, int32_t dest_x, int32_t dest_y, int32_t width, int32_t height);
3867 }
3868 */
3869
3870
2/2
✓ Branch 0 taken 7489601 times.
✓ Branch 1 taken 32321 times.
7521922 bool nosubscr = (tmpscr->flags3&fNOSUBSCR && !(tmpscr->flags3&fNOSUBSCROFFSET));
3871
3872
2/2
✓ Branch 0 taken 7489601 times.
✓ Branch 1 taken 32321 times.
7521922 if(nosubscr)
3873 {
3874 32321 rectfill(panorama,0,0,255,passive_subscreen_height/2,0);
3875 32321 rectfill(panorama,0,168+passive_subscreen_height/2,255,168+passive_subscreen_height-1,0);
3876 32321 blit(wavybuf,panorama,0,playing_field_offset,0,passive_subscreen_height/2,256,224-passive_subscreen_height);
3877 32321 }
3878
3879 //TODO: Optimize blit 'overcalls' -Gleeok
3880
2/2
✓ Branch 0 taken 32321 times.
✓ Branch 1 taken 7489601 times.
7521922 BITMAP *source = nosubscr ? panorama : wavybuf;
3881 7521922 blit(source,framebuf,0,0,0,0,256,224);
3882
3883 7521922 update_hw_screen();
3884 7521922 }
3885
3886 //----------------------------------------------------------------
3887
3888 PALETTE sys_pal;
3889
3890 int32_t onGUISnapshot()
3891 {
3892 char buf[200];
3893 int32_t num=0;
3894 bool realpal=(key[KEY_ZC_LCONTROL] || key[KEY_ZC_RCONTROL]);
3895 do
3896 {
3897 sprintf(buf, "%szc_screen%05d.%s", get_snap_str(), ++num, snapshotformat_str[SnapshotFormat][1]);
3898 }
3899 while(num<99999 && exists(buf));
3900
3901 BITMAP *b = create_bitmap_ex(8,resx,resy);
3902
3903 if(b)
3904 {
3905 if(MenuOpen)
3906 {
3907 //Cannot load game's palette while GUI elements are in focus. -Z
3908 //If there is a way to do this, then I have missed it.
3909 /*
3910 game_pal();
3911 RAMpal[253] = _RGB(0,0,0);
3912 RAMpal[254] = _RGB(63,63,63);
3913 zc_set_palette_range(RAMpal,0,255,false);
3914 memcpy(RAMpal, snappal, sizeof(snappal));
3915 create_rgb_table(&rgb_table, RAMpal, NULL);
3916 create_zc_trans_table(&trans_table, RAMpal, 128, 128, 128);
3917 memcpy(&trans_table2, &trans_table, sizeof(COLOR_MAP));
3918
3919 for(int32_t q=0; q<PAL_SIZE; q++)
3920 {
3921 trans_table2.data[0][q] = q;
3922 trans_table2.data[q][q] = q;
3923 }
3924 */
3925 //ringcolor(false);
3926 //get_palette(RAMpal);
3927 blit(screen,b,0,0,0,0,resx,resy);
3928 //al_trace("Menu Open\n");
3929 //game_pal();
3930 //PALETTE temppal;
3931 //get_palette(temppal);
3932 //system_pal();
3933 save_bitmap(buf,b,sys_pal);
3934 //save_bitmap(buf,b,RAMpal);
3935 //save_bitmap(buf,b,snappal);
3936 }
3937 else
3938 {
3939 blit(screen,b,0,0,0,0,resx,resy);
3940 save_bitmap(buf,b,realpal?sys_pal:RAMpal);
3941 }
3942 destroy_bitmap(b);
3943 }
3944
3945 return D_O_K;
3946 }
3947
3948 int32_t onNonGUISnapshot()
3949 {
3950 PALETTE temppal;
3951 get_palette(temppal);
3952 bool realpal=(zc_getkey(KEY_ZC_LCONTROL, true) || zc_getkey(KEY_ZC_RCONTROL, true));
3953
3954 char buf[200];
3955 int32_t num=0;
3956
3957 do
3958 {
3959 sprintf(buf, "%szc_screen%05d.%s", get_snap_str(), ++num, snapshotformat_str[SnapshotFormat][1]);
3960 }
3961 while(num<99999 && exists(buf));
3962
3963 save_bitmap(buf,framebuf,realpal?temppal:RAMpal);
3964
3965 return D_O_K;
3966 }
3967
3968 int32_t onSnapshot()
3969 {
3970 if(zc_getkey(KEY_LSHIFT, true)||zc_getkey(KEY_RSHIFT, true))
3971 {
3972 onGUISnapshot();
3973 }
3974 else
3975 {
3976 onNonGUISnapshot();
3977 }
3978
3979 return D_O_K;
3980 }
3981
3982 int32_t onSaveMapPic()
3983 {
3984 int32_t mapres2 = 0;
3985 char buf[200];
3986 int32_t num=0;
3987 mapscr tmpscr_b[2];
3988 mapscr tmpscr_c[6];
3989 BITMAP* _screen_draw_buffer = NULL;
3990 _screen_draw_buffer = create_bitmap_ex(8,256,224);
3991 set_clip_state(_screen_draw_buffer,1);
3992
3993 for(int32_t i=0; i<6; ++i)
3994 {
3995 tmpscr_c[i] = tmpscr2[i];
3996 tmpscr2[i].zero_memory();
3997
3998 if(i>=2)
3999 {
4000 continue;
4001 }
4002
4003 tmpscr_b[i] = tmpscr[i];
4004 tmpscr[i].zero_memory();
4005 }
4006
4007 do
4008 {
4009 sprintf(buf, "%szc_screen%05d.png", get_snap_str(), ++num);
4010 }
4011 while(num<99999 && exists(buf));
4012
4013 BITMAP* mappic = NULL;
4014
4015
4016 bool done=false, redraw=true;
4017
4018 mappic = create_bitmap_ex(8,(256*16)>>mapres,(176*8)>>mapres);
4019
4020 if(!mappic)
4021 {
4022 system_pal();
4023 jwin_alert("View Map","Not enough memory.",NULL,NULL,"OK",NULL,13,27,get_zc_font(font_lfont));
4024 game_pal();
4025 return D_O_K;;
4026 }
4027
4028 // draw the map
4029 set_clip_rect(_screen_draw_buffer, 0, 0, _screen_draw_buffer->w, _screen_draw_buffer->h);
4030
4031 for(int32_t y=0; y<8; y++)
4032 {
4033 for(int32_t x=0; x<16; x++)
4034 {
4035 if(!displayOnMap(x, y))
4036 {
4037 rectfill(_screen_draw_buffer, 0, 0, 255, 223, WHITE);
4038 }
4039 else
4040 {
4041 int32_t s = (y<<4) + x;
4042 loadscr2(1,s,-1);
4043
4044 for(int32_t i=0; i<6; i++)
4045 {
4046 if(tmpscr[1].layermap[i]<=0)
4047 continue;
4048
4049 if((ZCMaps[tmpscr[1].layermap[i]-1].tileWidth==ZCMaps[currmap].tileWidth) &&
4050 (ZCMaps[tmpscr[1].layermap[i]-1].tileHeight==ZCMaps[currmap].tileHeight))
4051 {
4052 const int32_t _mapsSize = (ZCMaps[currmap].tileWidth)*(ZCMaps[currmap].tileHeight);
4053
4054 tmpscr2[i]=TheMaps[(tmpscr[1].layermap[i]-1)*MAPSCRS+tmpscr[1].layerscreen[i]];
4055 }
4056 }
4057
4058 if(XOR((tmpscr+1)->flags7&fLAYER2BG, DMaps[currdmap].flags&dmfLAYER2BG)) do_layer(_screen_draw_buffer, 0, 2, tmpscr+1, -256, playing_field_offset, 2);
4059
4060 if(XOR((tmpscr+1)->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG)) do_layer(_screen_draw_buffer, 0, 3, tmpscr+1, -256, playing_field_offset, 2);
4061
4062 putscr(_screen_draw_buffer,256,0,tmpscr+1);
4063 do_layer(_screen_draw_buffer, 0, 1, tmpscr+1, -256, playing_field_offset, 2);
4064
4065 if(!XOR((tmpscr+1)->flags7&fLAYER2BG, DMaps[currdmap].flags&dmfLAYER2BG)) do_layer(_screen_draw_buffer, 0, 2, tmpscr+1, -256, playing_field_offset, 2);
4066
4067 putscrdoors(_screen_draw_buffer,256,0,tmpscr+1);
4068 do_layer(_screen_draw_buffer, -2, 0, tmpscr+1, -256, playing_field_offset, 2);
4069 if(get_bit(quest_rules, qr_PUSHBLOCK_LAYER_1_2))
4070 {
4071 do_layer(_screen_draw_buffer, -2, 1, tmpscr+1, -256, playing_field_offset, 2);
4072 do_layer(_screen_draw_buffer, -2, 2, tmpscr+1, -256, playing_field_offset, 2);
4073 }
4074 do_layer(_screen_draw_buffer, -3, 0, tmpscr+1, -256, playing_field_offset, 2); // Freeform combos!
4075
4076 if(!XOR((tmpscr+1)->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG)) do_layer(_screen_draw_buffer, 0, 3, tmpscr+1, -256, playing_field_offset, 2);
4077
4078 do_layer(_screen_draw_buffer, 0, 4, tmpscr+1, -256, playing_field_offset, 2);
4079 do_layer(_screen_draw_buffer, -1, 0, tmpscr+1, -256, playing_field_offset, 2);
4080 if(get_bit(quest_rules, qr_OVERHEAD_COMBOS_L1_L2))
4081 {
4082 do_layer(_screen_draw_buffer, -1, 1, tmpscr+1, -256, playing_field_offset, 2);
4083 do_layer(_screen_draw_buffer, -1, 2, tmpscr+1, -256, playing_field_offset, 2);
4084 }
4085 do_layer(_screen_draw_buffer, 0, 5, tmpscr+1, -256, playing_field_offset, 2);
4086 do_layer(_screen_draw_buffer, 0, 6, tmpscr+1, -256, playing_field_offset, 2);
4087
4088 }
4089
4090 stretch_blit(_screen_draw_buffer, mappic, 256, 0, 256, 176, x<<(8-mapres), (y*176)>>mapres, 256>>mapres, 176>>mapres);
4091 }
4092 }
4093
4094 for(int32_t i=0; i<6; ++i)
4095 {
4096 tmpscr2[i]=tmpscr_c[i];
4097
4098 if(i>=2)
4099 {
4100 continue;
4101 }
4102
4103 tmpscr[i]=tmpscr_b[i];
4104 }
4105
4106 save_bitmap(buf,mappic,RAMpal);
4107 destroy_bitmap(mappic);
4108 destroy_bitmap(_screen_draw_buffer);
4109 return D_O_K;
4110 }
4111
4112 /*
4113 int32_t onSaveMapPic()
4114 {
4115 BITMAP* mappic = NULL;
4116 BITMAP* _screen_draw_buffer = NULL;
4117 _screen_draw_buffer = create_bitmap_ex(8,256,224);
4118 int32_t mapres2 = 0;
4119 char buf[20];
4120 int32_t num=0;
4121 set_clip_state(_screen_draw_buffer,1);
4122 set_clip_rect(_screen_draw_buffer,0,0,_screen_draw_buffer->w, _screen_draw_buffer->h);
4123
4124 do
4125 {
4126 sprintf(buf, "zelda%03d.png", ++num);
4127 }
4128 while(num<999 && exists(buf));
4129
4130 // if(!mappic) {
4131 mappic = create_bitmap_ex(8,(256*16)>>mapres2,(176*8)>>mapres2);
4132
4133 if(!mappic)
4134 {
4135 system_pal();
4136 jwin_alert("Save Map Picture","Not enough memory.",NULL,NULL,"OK",NULL,13,27,get_zc_font(font_lfont));
4137 game_pal();
4138 return D_O_K;
4139 }
4140
4141 // }
4142
4143 int32_t layermap, layerscreen;
4144 int32_t x2=0;
4145
4146 // draw the map
4147 for(int32_t y=0; y<8; y++)
4148 {
4149 for(int32_t x=0; x<16; x++)
4150 {
4151 int32_t s = (y<<4) + x;
4152
4153 if(!displayOnMap(x, y))
4154 {
4155 rectfill(_screen_draw_buffer, 0, 0, 255, 223, WHITE);
4156 }
4157 else
4158 {
4159 loadscr(TEMPSCR_FUNCTION_SWAP_SPACE,currdmap,s,-1,false);
4160 putscr(_screen_draw_buffer, 0, 0, tmpscr+1);
4161
4162 for(int32_t k=0; k<4; k++)
4163 {
4164 if(k==2)
4165 {
4166 putscrdoors(_screen_draw_buffer, 0, 0, tmpscr+1);
4167 }
4168
4169 layermap=TheMaps[currmap*MAPSCRS+s].layermap[k]-1;
4170
4171 if(layermap>-1)
4172 {
4173 layerscreen=layermap*MAPSCRS+TheMaps[currmap*MAPSCRS+s].layerscreen[k];
4174
4175 if(TheMaps[currmap*MAPSCRS+s].layeropacity[k]==255)
4176 {
4177 for(int32_t i=0; i<176; i++)
4178 {
4179 overcombo(_screen_draw_buffer,((i&15)<<4)+x2,(i&0xF0),TheMaps[layerscreen].data[i],TheMaps[layerscreen].cset[i]);
4180 }
4181 }
4182 else
4183 {
4184 for(int32_t i=0; i<176; i++)
4185 {
4186 overcombotranslucent(_screen_draw_buffer,((i&15)<<4)+x2,(i&0xF0),TheMaps[layerscreen].data[i],TheMaps[layerscreen].cset[i],TheMaps[currmap*MAPSCRS+s].layeropacity[k]);
4187 }
4188 }
4189 }
4190 }
4191
4192 for(int32_t i=0; i<176; i++)
4193 {
4194 // if (COMBOTYPE((i&15)<<4,i&0xF0)==cOLD_OVERHEAD)
4195 if(combo_class_buf[COMBOTYPE((i&15)<<4,i&0xF0)].overhead)
4196 {
4197 overcombo(_screen_draw_buffer,((i&15)<<4)+x2,(i&0xF0),MAPCOMBO((i&15)<<4,i&0xF0),MAPCSET((i&15)<<4,i&0xF0));
4198 }
4199 }
4200
4201 for(int32_t k=4; k<6; k++)
4202 {
4203 layermap=TheMaps[currmap*MAPSCRS+s].layermap[k]-1;
4204
4205 if(layermap>-1)
4206 {
4207 layerscreen=layermap*MAPSCRS+TheMaps[currmap*MAPSCRS+s].layerscreen[k];
4208
4209 if(TheMaps[currmap*MAPSCRS+s].layeropacity[k]==255)
4210 {
4211 for(int32_t i=0; i<176; i++)
4212 {
4213 overcombo(_screen_draw_buffer,((i&15)<<4)+x2,(i&0xF0),TheMaps[layerscreen].data[i],TheMaps[layerscreen].cset[i]);
4214 }
4215 }
4216 else
4217 {
4218 for(int32_t i=0; i<176; i++)
4219 {
4220 overcombotranslucent(_screen_draw_buffer,((i&15)<<4)+x2,(i&0xF0),TheMaps[layerscreen].data[i],TheMaps[layerscreen].cset[i],TheMaps[currmap*MAPSCRS+s].layeropacity[k]);
4221 }
4222 }
4223 }
4224 }
4225 }
4226
4227 stretch_blit(_screen_draw_buffer, mappic, 0, 0, 256, 176,
4228 x<<(8-mapres2), (y*176)>>mapres2, 256>>mapres2, 176>>mapres2);
4229 }
4230
4231 }
4232
4233 save_bitmap(buf,mappic,RAMpal);
4234 destroy_bitmap(mappic);
4235 destroy_bitmap(_screen_draw_buffer);
4236 return D_O_K;
4237 }
4238 */
4239
4240 14 void f_Quit(int32_t type)
4241 {
4242
2/4
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 14 times.
✗ Branch 3 not taken.
14 if(type==qQUIT && !Playing)
4243 return;
4244
4245 14 bool from_menu = is_sys_pal;
4246
4247
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(!from_menu)
4248 {
4249 14 music_pause();
4250 14 pause_all_sfx();
4251 14 }
4252 14 enter_sys_pal();
4253 14 clear_keybuf();
4254
4255
2/4
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 14 times.
14 if (replay_is_active() && replay_get_version() <= 9)
4256 14 replay_poll();
4257
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if (replay_is_replaying())
4258 14 replay_peek_quit();
4259
4260
1/2
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
14 if (!replay_is_replaying())
4261 switch(type)
4262 {
4263 case qQUIT:
4264 onQuit();
4265 break;
4266
4267 case qRESET:
4268 onReset();
4269 break;
4270
4271 case qEXIT:
4272 onExit();
4273 break;
4274 }
4275
4276
1/2
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
14 if(Quit)
4277 {
4278 14 kill_sfx();
4279 14 music_stop();
4280 14 exit_sys_pal();
4281 14 update_hw_screen();
4282 14 }
4283 else
4284 {
4285 exit_sys_pal();
4286 if(!from_menu)
4287 {
4288 music_resume();
4289 resume_all_sfx();
4290 }
4291 }
4292
4293
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(!from_menu)
4294 14 eat_buttons();
4295
4296 14 zc_readrawkey(KEY_ESC);
4297
4298 14 zc_readrawkey(KEY_ENTER);
4299 14 }
4300
4301 //----------------------------------------------------------------
4302
4303 int32_t onNoWalls()
4304 {
4305 cheats_enqueue(Cheat::Walls);
4306 return D_O_K;
4307 }
4308
4309 int32_t onIgnoreSideview()
4310 {
4311 cheats_enqueue(Cheat::IgnoreSideView);
4312 return D_O_K;
4313 }
4314
4315 7521864 int32_t input_idle(bool checkmouse)
4316 {
4317 static int32_t mx, my, mz, mb;
4318
4319
4/6
✓ Branch 0 taken 7521864 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1928083 times.
✓ Branch 3 taken 5593781 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1928083 times.
9449947 if(keypressed() || zc_key_pressed() ||
4320
4/8
✓ Branch 0 taken 1928083 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1928083 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1928083 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1928083 times.
✗ Branch 7 not taken.
1928083 (checkmouse && (mx != mouse_x || my != mouse_y || mz != mouse_z || mb != mouse_b)))
4321 {
4322 5593781 idle_count = 0;
4323
4324
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5593781 times.
5593781 if(active_count < MAX_ACTIVE)
4325 {
4326 5593781 ++active_count;
4327 5593781 }
4328 5593781 }
4329
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1928083 times.
1928083 else if(idle_count < MAX_IDLE)
4330 {
4331 1928083 ++idle_count;
4332 1928083 active_count = 0;
4333 1928083 }
4334
4335 7521864 mx = mouse_x;
4336 7521864 my = mouse_y;
4337 7521864 mz = mouse_z;
4338 7521864 mb = mouse_b;
4339
4340 7521864 return idle_count;
4341 }
4342
4343 int32_t onGoFast()
4344 {
4345 cheats_enqueue(Cheat::Fast);
4346 return D_O_K;
4347 }
4348
4349 int32_t onKillCheat()
4350 {
4351 cheats_enqueue(Cheat::Kill);
4352 return D_O_K;
4353 }
4354
4355 int32_t onSecretsCheat()
4356 {
4357 cheats_enqueue(Cheat::TrigSecrets);
4358 return D_O_K;
4359 }
4360 int32_t onSecretsCheatPerm()
4361 {
4362 cheats_enqueue(Cheat::TrigSecretsPerm);
4363 return D_O_K;
4364 }
4365
4366 int32_t onShowLayer0()
4367 {
4368 show_layer_0 = !show_layer_0;
4369 return D_O_K;
4370 }
4371 int32_t onShowLayer1()
4372 {
4373 show_layer_1 = !show_layer_1;
4374 return D_O_K;
4375 }
4376 int32_t onShowLayer2()
4377 {
4378 show_layer_2 = !show_layer_2;
4379 return D_O_K;
4380 }
4381 int32_t onShowLayer3()
4382 {
4383 show_layer_3 = !show_layer_3;
4384 return D_O_K;
4385 }
4386 int32_t onShowLayer4()
4387 {
4388 show_layer_4 = !show_layer_4;
4389 return D_O_K;
4390 }
4391 int32_t onShowLayer5()
4392 {
4393 show_layer_5 = !show_layer_5;
4394 return D_O_K;
4395 }
4396 int32_t onShowLayer6()
4397 {
4398 show_layer_6 = !show_layer_6;
4399 return D_O_K;
4400 }
4401 int32_t onShowLayerO()
4402 {
4403 show_layer_over=!show_layer_over;
4404 return D_O_K;
4405 }
4406 int32_t onShowLayerP()
4407 {
4408 show_layer_push=!show_layer_push;
4409 return D_O_K;
4410 }
4411 int32_t onShowLayerS()
4412 {
4413 show_sprites=!show_sprites;
4414 return D_O_K;
4415 }
4416 int32_t onShowLayerF()
4417 {
4418 show_ffcs=!show_ffcs;
4419 return D_O_K;
4420 }
4421 int32_t onShowLayerW()
4422 {
4423 show_walkflags=!show_walkflags;
4424 if(show_walkflags)
4425 show_effectflags = false;
4426 return D_O_K;
4427 }
4428 int32_t onShowLayerE()
4429 {
4430 show_effectflags=!show_effectflags;
4431 if(show_effectflags)
4432 show_walkflags = false;
4433 return D_O_K;
4434 }
4435 int32_t onShowFFScripts()
4436 {
4437 show_ff_scripts=!show_ff_scripts;
4438 return D_O_K;
4439 }
4440 int32_t onShowHitboxes()
4441 {
4442 show_hitboxes=!show_hitboxes;
4443 return D_O_K;
4444 }
4445 int32_t onShowInfoOpacity()
4446 {
4447 info_opacity = vbound(getnumber("Debug Info Opacity",info_opacity),0,255);
4448 zc_set_config("zc","debug_info_opacity",info_opacity);
4449 return D_O_K;
4450 }
4451
4452 int32_t onLightSwitch()
4453 {
4454 cheats_enqueue(Cheat::Light);
4455 return D_O_K;
4456 }
4457
4458 int32_t onGoTo();
4459 int32_t onGoToComplete();
4460
4461 7521864 void syskeys()
4462 {
4463 7521864 update_system_keys();
4464
4465 int32_t oldtitle_version;
4466
4467
1/2
✓ Branch 0 taken 7521864 times.
✗ Branch 1 not taken.
7521864 if(close_button_quit)
4468 {
4469 close_button_quit=false;
4470 f_Quit(qEXIT);
4471 }
4472
4473 7521864 poll_joystick();
4474
4475
2/10
✓ Branch 0 taken 7521864 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 7521864 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
7521864 if(rMbtn() || (gui_mouse_b() && !mouse_down && ClickToFreeze &&!disableClickToFreeze))
4476 {
4477 oldtitle_version=title_version;
4478 System();
4479 }
4480
4481 7521864 mouse_down=gui_mouse_b();
4482
4483
1/2
✓ Branch 0 taken 7521864 times.
✗ Branch 1 not taken.
7521864 if(zc_read_system_key(KEY_F1))
4484 {
4485 if(zc_get_system_key(KEY_ZC_LCONTROL) || zc_get_system_key(KEY_ZC_RCONTROL))
4486 {
4487 halt=!halt;
4488 //zinit.subscreen=(zinit.subscreen+1)%ssdtMAX;
4489 }
4490 else
4491 {
4492 Throttlefps=!Throttlefps;
4493 zc_set_config(cfg_sect,"throttlefps", (int32_t)Throttlefps);
4494 logic_counter=0;
4495 }
4496 }
4497
4498 // if(zc_readkey(KEY_F1)) Vsync=!Vsync;
4499 /*
4500 if(zc_readkey(KEY_F1)) set_bit(QHeader.rules4,qr4_NEWENEMYTILES,
4501 1-((get_bit(QHeader.rules4,qr4_NEWENEMYTILES))));
4502 */
4503
4504
1/2
✓ Branch 0 taken 7521864 times.
✗ Branch 1 not taken.
7521864 if(zc_read_system_key(KEY_F2))
4505 {
4506 ShowFPS=!ShowFPS;
4507 zc_set_config(cfg_sect,"showfps",(int32_t)ShowFPS);
4508 }
4509
4510
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 7521864 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
7521864 if(zc_read_system_key(KEY_F3) && Playing) Paused=!Paused;
4511
4512
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 7521864 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
7521864 if(zc_read_system_key(KEY_F4) && Playing)
4513 {
4514 Paused=true;
4515 Advance=true;
4516 }
4517
4518
1/2
✓ Branch 0 taken 7521864 times.
✗ Branch 1 not taken.
7521864 if(zc_read_system_key(KEY_F6)) onTryQuit();
4519
4520 #ifndef ALLEGRO_MACOSX
4521
1/2
✓ Branch 0 taken 7521864 times.
✗ Branch 1 not taken.
7521864 if(zc_read_system_key(KEY_F9)) f_Quit(qRESET);
4522
4523
1/2
✓ Branch 0 taken 7521864 times.
✗ Branch 1 not taken.
7521864 if(zc_read_system_key(KEY_F10)) f_Quit(qEXIT);
4524 #else
4525 if(zc_read_system_key(KEY_F7)) f_Quit(qRESET);
4526
4527 if(zc_read_system_key(KEY_F8)) f_Quit(qEXIT);
4528 #endif
4529
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 7521864 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
7521864 if(zc_read_system_key(KEY_F5)&&(Playing && currscr<128 && DMaps[currdmap].flags&dmfVIEWMAP)) onSaveMapPic();
4530
4531
1/2
✓ Branch 0 taken 7521864 times.
✗ Branch 1 not taken.
7521864 if (zc_read_system_key(KEY_F12))
4532 {
4533 onSnapshot();
4534 }
4535
4536
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 7521864 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
7521864 if(debug_enabled && zc_read_system_key(KEY_TAB))
4537 set_debug(!get_debug());
4538
4539
1/2
✓ Branch 0 taken 7521864 times.
✗ Branch 1 not taken.
7521864 if(CheatModifierKeys())
4540 {
4541 for(Cheat c = (Cheat)1; c < Cheat::Last; c = (Cheat)(c+1))
4542 {
4543 if(!bindable_cheat(c))
4544 continue;
4545 if(get_debug() || cheat >= cheat_lvl(c))
4546 {
4547 if(checkcheat(c))
4548 cheats_hit_bind(c);
4549 }
4550 }
4551 }
4552
4553
1/2
✓ Branch 0 taken 7521864 times.
✗ Branch 1 not taken.
7521864 if(volkeys)
4554 {
4555 if(zc_read_system_key(KEY_PGUP)) master_volume(-1,midi_volume+8);
4556
4557 if(zc_read_system_key(KEY_PGDN)) master_volume(-1,midi_volume==255?248:midi_volume-8);
4558
4559 if(zc_read_system_key(KEY_HOME)) master_volume(digi_volume+8,-1);
4560
4561 if(zc_read_system_key(KEY_END)) master_volume(digi_volume==255?248:digi_volume-8,-1);
4562 }
4563
4564
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 7521864 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
7521864 if(!get_debug() || !SystemKeys || replay_is_replaying())
4565 7521864 goto bottom;
4566
4567 if(zc_readkey(KEY_D))
4568 {
4569 details = !details;
4570 rectfill(screen,0,0,319,7,BLACK);
4571 rectfill(screen,0,8,31,239,BLACK);
4572 rectfill(screen,288,8,319,239,BLACK);
4573 rectfill(screen,32,232,287,239,BLACK);
4574 }
4575
4576 if(zc_readkey(KEY_P)) Paused=!Paused;
4577
4578 //if(zc_readkey(KEY_P)) centerHero();
4579 if(zc_readkey(KEY_A))
4580 {
4581 Paused=true;
4582 Advance=true;
4583 }
4584
4585 if(zc_readkey(KEY_G)) db=(db==999)?0:999;
4586 #ifndef ALLEGRO_MACOSX
4587 if(zc_readkey(KEY_F8)) Showpal=!Showpal;
4588
4589 if(zc_readkey(KEY_F7))
4590 {
4591 Matrix(ss_speed, ss_density, 0);
4592 game_pal();
4593 }
4594 #else
4595 // The reason these are different on Mac in the first place is that
4596 // the OS doesn't let us use F9 and F10...
4597 if(zc_readkey(KEY_F10)) Showpal=!Showpal;
4598
4599 if(zc_readkey(KEY_F9))
4600 {
4601 Matrix(ss_speed, ss_density, 0);
4602 game_pal();
4603 }
4604 #endif
4605 if(zc_readkey(KEY_PLUS_PAD) || zc_readkey(KEY_EQUALS))
4606 {
4607 //change containers
4608 if(zc_getkey(KEY_ZC_LCONTROL) || zc_getkey(KEY_ZC_RCONTROL))
4609 {
4610 //magic containers
4611 if(zc_getkey(KEY_LSHIFT) || zc_getkey(KEY_RSHIFT))
4612 {
4613 game->set_maxmagic(zc_min(game->get_maxmagic()+game->get_mp_per_block(),game->get_mp_per_block()*8));
4614 }
4615 else
4616 {
4617 game->set_maxlife(zc_min(game->get_maxlife()+game->get_hp_per_heart(),game->get_hp_per_heart()*24));
4618 }
4619 }
4620 else
4621 {
4622 if(zc_getkey(KEY_LSHIFT) || zc_getkey(KEY_RSHIFT))
4623 {
4624 game->set_magic(zc_min(game->get_magic()+1,game->get_maxmagic()));
4625 }
4626 else
4627 {
4628 game->set_life(zc_min(game->get_life()+1,game->get_maxlife()));
4629 }
4630 }
4631 }
4632
4633 if(zc_readkey(KEY_MINUS_PAD) || zc_readkey(KEY_MINUS))
4634 {
4635 //change containers
4636 if(zc_getkey(KEY_ZC_LCONTROL) || zc_getkey(KEY_ZC_RCONTROL))
4637 {
4638 //magic containers
4639 if(zc_getkey(KEY_LSHIFT) || zc_getkey(KEY_RSHIFT))
4640 {
4641 game->set_maxmagic(zc_max(game->get_maxmagic()-game->get_mp_per_block(),0));
4642 game->set_magic(zc_min(game->get_maxmagic(), game->get_magic()));
4643 //heart containers
4644 }
4645 else
4646 {
4647 game->set_maxlife(zc_max(game->get_maxlife()-game->get_hp_per_heart(),game->get_hp_per_heart()));
4648 game->set_life(zc_min(game->get_maxlife(), game->get_life()));
4649 }
4650 }
4651 else
4652 {
4653 if(zc_getkey(KEY_LSHIFT) || zc_getkey(KEY_RSHIFT))
4654 {
4655 game->set_magic(zc_max(game->get_magic()-1,0));
4656 }
4657 else
4658 {
4659 game->set_life(zc_max(game->get_life()-1,0));
4660 }
4661 }
4662 }
4663
4664 if(zc_readkey(KEY_COMMA)) jukebox(currmidi-1);
4665
4666 if(zc_readkey(KEY_STOP)) jukebox(currmidi+1);
4667
4668 verifyBothWeapons();
4669
4670 bottom:
4671
4672
1/2
✓ Branch 0 taken 7521864 times.
✗ Branch 1 not taken.
7521864 if(input_idle(true) > after_time())
4673 {
4674 Matrix(ss_speed, ss_density, 0);
4675 game_pal();
4676 }
4677 7521864 }
4678
4679 330136 void checkQuitKeys()
4680 {
4681 #ifndef ALLEGRO_MACOSX
4682
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 330136 times.
330136 if(key[KEY_F9]) f_Quit(qRESET);
4683
4684
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 330136 times.
330136 if(key[KEY_F10]) f_Quit(qEXIT);
4685 #else
4686 if(key[KEY_F7]) f_Quit(qRESET);
4687
4688 if(key[KEY_F8]) f_Quit(qEXIT);
4689 #endif
4690 330136 }
4691
4692 7521864 bool CheatModifierKeys()
4693 {
4694 // Cheats are replayed via the X cheat step, no need to check for keyboard input
4695 // to trigger cheats.
4696
1/2
✓ Branch 0 taken 7521864 times.
✗ Branch 1 not taken.
7521864 if (replay_is_replaying())
4697 7521864 return false;
4698
4699 if ( ( cheat_modifier_keys[0] > 0 && key[cheat_modifier_keys[0]] ) ||
4700 ( cheat_modifier_keys[1] > 0 && key[cheat_modifier_keys[1]] ) ||
4701 (cheat_modifier_keys[0] <= 0 && cheat_modifier_keys[1] <= 0))
4702 {
4703 if ( ( cheat_modifier_keys[2] <= 0 || key[cheat_modifier_keys[2]] ) ||
4704 ( cheat_modifier_keys[3] > 0 && key[cheat_modifier_keys[3]] ) ||
4705 (cheat_modifier_keys[2] <= 0 && cheat_modifier_keys[3] <= 0))
4706 {
4707 return true;
4708 }
4709 }
4710 return false;
4711 7521864 }
4712
4713 //99:05:54, for some reason?
4714 #define OLDMAXTIME 21405240
4715 //9000:00:00, the highest even-thousand hour fitting within 32b signed. This is 375 *DAYS*.
4716 #define MAXTIME 1944000000
4717
4718 7521922 void advanceframe(bool allowwavy, bool sfxcleanup, bool allowF6Script)
4719 {
4720
2/2
✓ Branch 0 taken 7243581 times.
✓ Branch 1 taken 278341 times.
7521922 if(zcmusic!=NULL)
4721 {
4722 278341 zcmusic_poll();
4723 278341 }
4724
4725 7521922 updatescr(allowwavy);
4726
4727 7521922 Advance=false;
4728
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 7521922 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 7521922 times.
7521922 while(Paused && !Advance && !Quit)
4729 {
4730 // have to call this, otherwise we'll get an infinite loop
4731 syskeys();
4732 if(allowF6Script)
4733 {
4734 FFCore.runF6Engine();
4735 }
4736 throttleFPS();
4737
4738 #ifdef _WIN32
4739
4740 if(use_dwm_flush)
4741 {
4742 do_DwmFlush();
4743 }
4744
4745 #endif
4746
4747 // to keep music playing
4748 if(zcmusic!=NULL)
4749 {
4750 zcmusic_poll();
4751 }
4752
4753 update_hw_screen();
4754 }
4755
4756
2/2
✓ Branch 0 taken 7521875 times.
✓ Branch 1 taken 47 times.
7521922 if(Quit)
4757 47 return;
4758
4759
3/4
✓ Branch 0 taken 7427449 times.
✓ Branch 1 taken 94426 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7427449 times.
7521875 if(Playing && game->get_time()<unsigned(get_bit(quest_rules,qr_GREATER_MAX_TIME) ? MAXTIME : OLDMAXTIME))
4760 7427449 game->change_time(1);
4761
4762
3/4
✓ Branch 0 taken 7521875 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1011251 times.
✓ Branch 3 taken 6510624 times.
7521875 if (!replay_is_active() || replay_get_version() >= 11)
4763
2/2
✓ Branch 0 taken 18202518 times.
✓ Branch 1 taken 1011251 times.
19213769 for (int i = 0; i < ZC_CONTROL_STATES; i++)
4764 19213769 down_control_states[i] = raw_control_state[i];
4765
4766
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 7521874 times.
7521875 if (replay_is_active())
4767 {
4768
2/2
✓ Branch 0 taken 1270462 times.
✓ Branch 1 taken 6251412 times.
7521874 if (replay_get_version() >= 3)
4769 6251412 replay_poll();
4770
4771
6/6
✓ Branch 0 taken 6510614 times.
✓ Branch 1 taken 1011250 times.
✓ Branch 2 taken 3089962 times.
✓ Branch 3 taken 3420652 times.
✓ Branch 4 taken 100535 times.
✓ Branch 5 taken 2989427 times.
7521874 if (replay_get_version() >= 11 || (replay_get_version() >= 6 && replay_get_version() < 8))
4772 1111785 replay_peek_input();
4773 7521864 }
4774
4775 7521875 load_control_called_this_frame = false;
4776
4777 7521875 poll_keyboard();
4778 7521875 update_keys();
4779
4780 7521875 ++frame;
4781
4782
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 7521864 times.
7521875 if (replay_is_replaying())
4783 7521864 replay_do_cheats();
4784 7521875 syskeys();
4785
4786 // The mouse variables can change from the mouse thread at anytime during a frame,
4787 // so save the result at the start so that replaying is consistent.
4788 7521875 script_mouse_x = gui_mouse_x();
4789 7521875 script_mouse_y = gui_mouse_y();
4790 7521875 script_mouse_z = mouse_z;
4791 7521875 script_mouse_b = mouse_b;
4792
4793 // Cheats used via the System menu (called by syskeys) will call cheats_enqueue. syskeys
4794 // is called just above, and in the paused loop above, so the queue-and-defer-slightly
4795 // approach here means it doesn't matter which call adds the cheat.
4796 7521875 cheats_execute_queued();
4797
4798
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 7521864 times.
7521875 if (replay_is_replaying())
4799 7521864 replay_peek_quit();
4800
2/2
✓ Branch 0 taken 7521861 times.
✓ Branch 1 taken 14 times.
7521875 if (GameFlags & GAMEFLAG_TRYQUIT)
4801 14 replay_step_quit(0);
4802
2/2
✓ Branch 0 taken 2201 times.
✓ Branch 1 taken 7519674 times.
7521875 if(allowF6Script)
4803 7519674 FFCore.runF6Engine();
4804
2/2
✓ Branch 0 taken 7521686 times.
✓ Branch 1 taken 189 times.
7521875 if (Quit)
4805 189 replay_step_quit(Quit);
4806 // Someday... maybe install a Turbo button here?
4807 7521875 throttleFPS();
4808
4809 #ifdef _WIN32
4810
4811 if(use_dwm_flush)
4812 {
4813 do_DwmFlush();
4814 }
4815
4816 #endif
4817
4818 //textprintf_ex(screen,font,0,72,254,BLACK,"%d %d", lastentrance, lastentrance_dmap);
4819
2/2
✓ Branch 0 taken 40867 times.
✓ Branch 1 taken 7481008 times.
7521875 if(sfxcleanup)
4820 7481008 sfx_cleanup();
4821 7521922 }
4822
4823 69 void zapout()
4824 {
4825 69 set_clip_rect(scrollbuf, 0, 0, scrollbuf->w, scrollbuf->h);
4826 69 blit(framebuf,scrollbuf,0,0,256,0,256,224);
4827
4828 69 FFCore.runGenericPassiveEngine(SCR_TIMING_END_FRAME);
4829 69 script_drawing_commands.Clear();
4830
4831 // zap out
4832
2/2
✓ Branch 0 taken 69 times.
✓ Branch 1 taken 1656 times.
1725 for(int32_t i=1; i<=24; i++)
4833 {
4834 1656 draw_fuzzy(i);
4835 1656 advanceframe(true);
4836
4837
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1656 times.
1656 if(Quit)
4838 {
4839 break;
4840 }
4841 1656 }
4842 69 }
4843
4844 69 void zapin()
4845 {
4846 69 FFCore.warpScriptCheck();
4847 69 draw_screen(tmpscr);
4848 69 set_clip_rect(scrollbuf, 0, 0, scrollbuf->w, scrollbuf->h);
4849 //put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,false,sspUP);
4850 69 blit(framebuf,scrollbuf,0,0,256,0,256,224);
4851
4852 // zap out
4853 69 FFCore.runGenericPassiveEngine(SCR_TIMING_END_FRAME);
4854
2/2
✓ Branch 0 taken 69 times.
✓ Branch 1 taken 1656 times.
1725 for(int32_t i=24; i>=1; i--)
4855 {
4856 1656 draw_fuzzy(i);
4857 1656 advanceframe(true);
4858
4859
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1656 times.
1656 if(Quit)
4860 {
4861 break;
4862 }
4863 1656 }
4864 69 }
4865
4866
4867 32 void wavyout(bool showhero)
4868 {
4869 32 draw_screen(tmpscr, showhero);
4870 //put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,false,sspUP);
4871
4872 32 BITMAP *wavebuf = create_bitmap_ex(8,288,224);
4873 32 clear_to_color(wavebuf,0);
4874 32 blit(framebuf,wavebuf,0,0,16,0,256,224);
4875
4876 static PALETTE wavepal;
4877
4878 int32_t ofs;
4879 32 int32_t amplitude=8;
4880
4881 32 int32_t wavelength=4;
4882 32 double palpos=0, palstep=4, palstop=126;
4883
4884 32 FFCore.runGenericPassiveEngine(SCR_TIMING_END_FRAME);
4885
2/2
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 1344 times.
1376 for(int32_t i=0; i<168; i+=wavelength)
4886 {
4887
2/2
✓ Branch 0 taken 344064 times.
✓ Branch 1 taken 1344 times.
345408 for(int32_t l=0; l<256; l++)
4888 {
4889 344064 wavepal[l].r=vbound(int32_t(RAMpal[l].r+((palpos/palstop)*(63-RAMpal[l].r))),0,63);
4890 344064 wavepal[l].g=vbound(int32_t(RAMpal[l].g+((palpos/palstop)*(63-RAMpal[l].g))),0,63);
4891 344064 wavepal[l].b=vbound(int32_t(RAMpal[l].b+((palpos/palstop)*(63-RAMpal[l].b))),0,63);
4892 344064 }
4893
4894 1344 palpos+=palstep;
4895
4896
1/2
✓ Branch 0 taken 1344 times.
✗ Branch 1 not taken.
1344 if(palpos>=0)
4897 {
4898 1344 hw_palette = &wavepal;
4899 1344 update_hw_pal = true;
4900 1344 }
4901 else
4902 {
4903 hw_palette = &RAMpal;
4904 update_hw_pal = true;
4905 }
4906
4907
2/2
✓ Branch 0 taken 225792 times.
✓ Branch 1 taken 1344 times.
227136 for(int32_t j=0; j+playing_field_offset<224; j++)
4908 {
4909
2/2
✓ Branch 0 taken 57802752 times.
✓ Branch 1 taken 225792 times.
58028544 for(int32_t k=0; k<256; k++)
4910 {
4911 57802752 ofs=0;
4912
4913
4/4
✓ Branch 0 taken 28213248 times.
✓ Branch 1 taken 29589504 times.
✓ Branch 2 taken 14106624 times.
✓ Branch 3 taken 14106624 times.
57802752 if((j<i)&&(j&1))
4914 {
4915 14106624 ofs=int32_t(zc::math::Sin((double(i+j)*2*PI/168.0))*amplitude);
4916 14106624 }
4917
4918 57802752 framebuf->line[j+playing_field_offset][k]=wavebuf->line[j+playing_field_offset][k+ofs+16];
4919 57802752 }
4920 225792 }
4921
4922 1344 advanceframe(true);
4923
4924 // animate_combos();
4925
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1344 times.
1344 if(Quit)
4926 break;
4927 1344 }
4928
4929 32 destroy_bitmap(wavebuf);
4930 32 }
4931
4932 32 void wavyin()
4933 {
4934 32 draw_screen(tmpscr);
4935 //put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,false,sspUP);
4936
4937 32 BITMAP *wavebuf = create_bitmap_ex(8,288,224);
4938 32 clear_to_color(wavebuf,0);
4939 32 blit(framebuf,wavebuf,0,0,16,0,256,224);
4940
4941 static PALETTE wavepal;
4942
4943 //Breaks dark rooms.
4944 //In any case I don't think we need this, since palette is already loaded in doWarp() (famous last words...) -DD
4945 /*
4946 loadfullpal();
4947 loadlvlpal(DMaps[currdmap].color);
4948 ringcolor(false);
4949 */
4950 32 refreshpal=false;
4951 int32_t ofs;
4952 32 int32_t amplitude=8;
4953 32 int32_t wavelength=4;
4954 32 double palpos=168, palstep=4, palstop=126;
4955
4956 32 FFCore.runGenericPassiveEngine(SCR_TIMING_END_FRAME);
4957
2/2
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 1344 times.
1376 for(int32_t i=0; i<168; i+=wavelength)
4958 {
4959
2/2
✓ Branch 0 taken 344064 times.
✓ Branch 1 taken 1344 times.
345408 for(int32_t l=0; l<256; l++)
4960 {
4961 344064 wavepal[l].r=vbound(int32_t(RAMpal[l].r+((palpos/palstop)*(63-RAMpal[l].r))),0,63);
4962 344064 wavepal[l].g=vbound(int32_t(RAMpal[l].g+((palpos/palstop)*(63-RAMpal[l].g))),0,63);
4963 344064 wavepal[l].b=vbound(int32_t(RAMpal[l].b+((palpos/palstop)*(63-RAMpal[l].b))),0,63);
4964 344064 }
4965
4966 1344 palpos-=palstep;
4967
4968
1/2
✓ Branch 0 taken 1344 times.
✗ Branch 1 not taken.
1344 if(palpos>=0)
4969 {
4970 1344 hw_palette = &wavepal;
4971 1344 update_hw_pal = true;
4972 1344 }
4973 else
4974 {
4975 hw_palette = &RAMpal;
4976 update_hw_pal = true;
4977 }
4978
4979
2/2
✓ Branch 0 taken 225792 times.
✓ Branch 1 taken 1344 times.
227136 for(int32_t j=0; j+playing_field_offset<224; j++)
4980 {
4981
2/2
✓ Branch 0 taken 57802752 times.
✓ Branch 1 taken 225792 times.
58028544 for(int32_t k=0; k<256; k++)
4982 {
4983 57802752 ofs=0;
4984
4985
4/4
✓ Branch 0 taken 29245440 times.
✓ Branch 1 taken 28557312 times.
✓ Branch 2 taken 14794752 times.
✓ Branch 3 taken 14450688 times.
57802752 if((j<(167-i))&&(j&1))
4986 {
4987 14450688 ofs=int32_t(zc::math::Sin((double(i+j)*2*PI/168.0))*amplitude);
4988 14450688 }
4989
4990 57802752 framebuf->line[j+playing_field_offset][k]=wavebuf->line[j+playing_field_offset][k+ofs+16];
4991 57802752 }
4992 225792 }
4993
4994 1344 advanceframe(true);
4995 // animate_combos();
4996
4997
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1344 times.
1344 if(Quit)
4998 break;
4999 1344 }
5000
5001 32 destroy_bitmap(wavebuf);
5002 32 }
5003
5004 1826 void blackscr(int32_t fcnt,bool showsubscr)
5005 {
5006 1826 reset_pal_cycling();
5007 1826 script_drawing_commands.Clear();
5008
5009 1826 FFCore.warpScriptCheck();
5010 1826 bool showtime = game->should_show_time();
5011
2/2
✓ Branch 0 taken 1826 times.
✓ Branch 1 taken 54710 times.
56536 while(fcnt>0)
5012 {
5013 54710 clear_bitmap(framebuf);
5014
5015
2/2
✓ Branch 0 taken 17490 times.
✓ Branch 1 taken 37220 times.
54710 if(showsubscr)
5016 {
5017 37220 put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,showtime,sspUP);
5018
3/4
✓ Branch 0 taken 37220 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 750 times.
✓ Branch 3 taken 36470 times.
37220 if(get_bit(quest_rules, qr_SCRIPTDRAWSINWARPS) || (get_bit(quest_rules, qr_PASSIVE_SUBSCRIPT_RUNS_WHEN_GAME_IS_FROZEN)))
5019 {
5020 750 do_script_draws(framebuf, tmpscr, 0, playing_field_offset);
5021 750 }
5022 37220 }
5023
5024 54710 advanceframe(true);
5025
5026
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 54710 times.
54710 if(Quit)
5027 break;
5028
5029 54710 --fcnt;
5030 }
5031 1826 }
5032
5033 645 void openscreen(int32_t shape)
5034 {
5035 645 reset_pal_cycling();
5036 645 black_opening_count=0;
5037
5038
3/4
✓ Branch 0 taken 98 times.
✓ Branch 1 taken 547 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 98 times.
645 if(COOLSCROLL || shape>-1)
5039 {
5040 547 open_black_opening(HeroX()+8, (HeroY()-HeroZ()-HeroFakeZ())+8+playing_field_offset, true, shape);
5041 547 return;
5042 }
5043 else
5044 {
5045 98 Hero.setDontDraw(true);
5046 98 show_subscreen_dmap_dots=false;
5047 98 show_subscreen_numbers=false;
5048 // show_subscreen_items=false;
5049 98 show_subscreen_life=false;
5050 }
5051
5052 98 int32_t x=128;
5053
5054 98 FFCore.warpScriptCheck();
5055
2/2
✓ Branch 0 taken 98 times.
✓ Branch 1 taken 7840 times.
7938 for(int32_t i=0; i<80; i++)
5056 {
5057 7840 draw_screen(tmpscr);
5058 //? draw_screen already draws the subscreen -DD
5059 //put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,false,sspUP);
5060 7840 x=128-(((i*128/80)/8)*8);
5061
5062
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7840 times.
7840 if(x>0)
5063 {
5064 7840 rectfill(framebuf,0,playing_field_offset,x,167+playing_field_offset,0);
5065 7840 rectfill(framebuf,256-x,playing_field_offset,255,167+playing_field_offset,0);
5066 7840 }
5067
5068 7840 advanceframe(true);
5069
5070
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7840 times.
7840 if(Quit)
5071 {
5072 break;
5073 }
5074 7840 }
5075
5076 98 Hero.setDontDraw(false);
5077 98 show_subscreen_items=true;
5078 98 show_subscreen_dmap_dots=true;
5079 645 }
5080
5081 void closescreen(int32_t shape)
5082 {
5083 reset_pal_cycling();
5084 black_opening_count=0;
5085
5086 if(COOLSCROLL || shape>-1)
5087 {
5088 close_black_opening(HeroX()+8, (HeroY()-HeroZ()-HeroFakeZ())+8+playing_field_offset, true, shape);
5089 return;
5090 }
5091 else
5092 {
5093 Hero.setDontDraw(true);
5094 show_subscreen_dmap_dots=false;
5095 show_subscreen_numbers=false;
5096 // show_subscreen_items=false;
5097 show_subscreen_life=false;
5098 }
5099
5100 int32_t x=128;
5101
5102 FFCore.warpScriptCheck();
5103 for(int32_t i=79; i>=0; --i)
5104 {
5105 draw_screen(tmpscr);
5106 //? draw_screen already draws the subscreen -DD
5107 //put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,false,sspUP);
5108 x=128-(((i*128/80)/8)*8);
5109
5110 if(x>0)
5111 {
5112 rectfill(framebuf,0,playing_field_offset,x,167+playing_field_offset,0);
5113 rectfill(framebuf,256-x,playing_field_offset,255,167+playing_field_offset,0);
5114 }
5115
5116 advanceframe(true);
5117
5118 if(Quit)
5119 {
5120 break;
5121 }
5122 }
5123
5124 Hero.setDontDraw(false);
5125 show_subscreen_items=true;
5126 show_subscreen_dmap_dots=true;
5127 }
5128
5129 175 int32_t TriforceCount()
5130 {
5131 175 int32_t c=0;
5132
5133
2/2
✓ Branch 0 taken 1400 times.
✓ Branch 1 taken 175 times.
1575 for(int32_t i=1; i<=8; i++)
5134
2/2
✓ Branch 0 taken 384 times.
✓ Branch 1 taken 1016 times.
2416 if(game->lvlitems[i]&liTRIFORCE)
5135 1016 ++c;
5136
5137 175 return c;
5138 }
5139
5140 int32_t onCustomGame()
5141 {
5142 int32_t file = getsaveslot();
5143
5144 if(file < 0)
5145 return D_O_K;
5146
5147 bool ret = (custom_game(file)!=0);
5148 return ret ? D_CLOSE : D_O_K;
5149 }
5150
5151 int32_t onContinue()
5152 {
5153 return D_CLOSE;
5154 }
5155
5156 int32_t onEsc() // Unused?? -L
5157 {
5158 return zc_getrawkey(KEY_ESC, true)?D_CLOSE:D_O_K;
5159 }
5160
5161 int32_t onVsync()
5162 {
5163 Throttlefps = !Throttlefps;
5164 zc_set_config(cfg_sect,"throttlefps", (int32_t)Throttlefps);
5165 return D_O_K;
5166 }
5167
5168 int32_t onWinPosSave()
5169 {
5170 SaveWinPos = !SaveWinPos;
5171 zc_set_config(cfg_sect,"save_window_position",(int32_t)SaveWinPos);
5172 return D_O_K;
5173 }
5174 int32_t onIntegerScaling()
5175 {
5176 scaleForceInteger = !scaleForceInteger;
5177 zc_set_config("zeldadx","scaling_force_integer",(int)scaleForceInteger);
5178 return D_O_K;
5179 }
5180 int32_t onStretchGame()
5181 {
5182 stretchGame = !stretchGame;
5183 zc_set_config("zeldadx","stretch_game_area",stretchGame?1:0);
5184 return D_O_K;
5185 }
5186
5187 int32_t onClickToFreeze()
5188 {
5189 ClickToFreeze = !ClickToFreeze;
5190 zc_set_config(cfg_sect,"clicktofreeze", (int32_t)ClickToFreeze);
5191 return D_O_K;
5192 }
5193
5194 int32_t OnSaveZCConfig()
5195 {
5196 if(jwin_alert3(
5197 "Save Configuration",
5198 "Are you sure that you wish to save your present configuration settings?",
5199 "This will overwrite your prior settings!",
5200 NULL,
5201 "&Yes",
5202 "&No",
5203 NULL,
5204 'y',
5205 'n',
5206 0,
5207 get_zc_font(font_lfont)) == 1)
5208 {
5209 save_game_configs();
5210 return D_O_K;
5211 }
5212 else return D_O_K;
5213 }
5214
5215 int32_t OnnClearQuestDir()
5216 {
5217 if(jwin_alert3(
5218 "Clear Current Directory Cache",
5219 "Are you sure that you wish to clear the current cached directory?",
5220 "This will default the current directory to the ROOT for this instance of ZC Player!",
5221 NULL,
5222 "&Yes",
5223 "&No",
5224 NULL,
5225 'y',
5226 'n',
5227 0,
5228 get_zc_font(font_lfont)) == 1)
5229 {
5230 zc_set_config("zeldadx","win_qst_dir","");
5231 flush_config_file();
5232 strcpy(qstdir,"");
5233 #ifdef __EMSCRIPTEN__
5234 em_sync_fs();
5235 #endif
5236 return D_O_K;
5237 }
5238 else return D_O_K;
5239 }
5240
5241
5242 int32_t onConsoleZASM()
5243 {
5244 if ( !zasm_debugger )
5245 {
5246 AlertDialog("WARNING: ZASM Debugger",
5247 "Enabling this will open the ZASM Debugger Console"
5248 "\nThis will likely grind ZC to a halt with lag."
5249 "\nTo make any use of this, it is suggested that you read"
5250 "\nthe documentation for 'void Breakpoint(char[] string);'"
5251 " in 'ZScript_Additions.txt'"
5252 "\nThis is not recommended for normal users,"
5253 " and is only intended for ZC developers,"
5254 "\nor quest developers coding directly in ZASM"
5255 "\nAre you sure that you wish to open the ZASM Debugger?",
5256 [&](bool ret,bool)
5257 {
5258 if(ret)
5259 {
5260 FFCore.ZASMPrint(true);
5261 }
5262 }).show();
5263 return D_O_K;
5264 }
5265 else
5266 {
5267 FFCore.ZASMPrint(false);
5268 return D_O_K;
5269 }
5270 }
5271
5272
5273 int32_t onConsoleZScript()
5274 {
5275 if ( !zscript_debugger )
5276 {
5277 AlertDialog("ZScript Debugger",
5278 "Enabling this will open the ZScript Debugger Console"
5279 "\nThis will display any messages logged by scripts,"
5280 " including script errors."
5281 "\nAre you sure that you wish to open the ZScript Debugger?",
5282 [&](bool ret,bool)
5283 {
5284 if(ret)
5285 {
5286 FFCore.ZScriptConsole(true);
5287 }
5288 }).show();
5289 return D_O_K;
5290 }
5291 else
5292 {
5293 FFCore.ZScriptConsole(false);
5294 return D_O_K;
5295 }
5296 }
5297
5298 int32_t onClrConsoleOnReload()
5299 {
5300 clearConsoleOnReload = !clearConsoleOnReload;
5301 zc_set_config("CONSOLE","clear_console_on_reload",clearConsoleOnReload?1:0);
5302 return D_O_K;
5303 }
5304 int32_t onClrConsoleOnLoad()
5305 {
5306 clearConsoleOnLoad = !clearConsoleOnLoad;
5307 zc_set_config("CONSOLE","clear_console_on_load",clearConsoleOnLoad?1:0);
5308 return D_O_K;
5309 }
5310
5311
5312 int32_t onFrameSkip()
5313 {
5314 FrameSkip = !FrameSkip;
5315 return D_O_K;
5316 }
5317
5318 int32_t onSaveDragResize()
5319 {
5320 SaveDragResize = !SaveDragResize;
5321 zc_set_config(cfg_sect,"save_drag_resize",(int32_t)SaveDragResize);
5322 return D_O_K;
5323 }
5324
5325 int32_t onDragAspect()
5326 {
5327 DragAspect = !DragAspect;
5328 zc_set_config(cfg_sect,"drag_aspect",(int32_t)DragAspect);
5329 return D_O_K;
5330 }
5331
5332 int32_t onTransLayers()
5333 {
5334 TransLayers = !TransLayers;
5335 zc_set_config(cfg_sect,"translayers",(int32_t)TransLayers);
5336 return D_O_K;
5337 }
5338
5339 int32_t onNESquit()
5340 {
5341 NESquit = !NESquit;
5342 zc_set_config(cfg_sect,"fastquit",(int32_t)NESquit);
5343 return D_O_K;
5344 }
5345
5346 int32_t onVolKeys()
5347 {
5348 volkeys = !volkeys;
5349 zc_set_config(sfx_sect,"volkeys",(int32_t)volkeys);
5350 return D_O_K;
5351 }
5352
5353 int32_t onShowFPS()
5354 {
5355 ShowFPS = !ShowFPS;
5356 zc_set_config(cfg_sect,"showfps",(int32_t)ShowFPS);
5357 return D_O_K;
5358 }
5359
5360 887579952 bool is_Fkey(int32_t k)
5361 {
5362
2/2
✓ Branch 0 taken 90262368 times.
✓ Branch 1 taken 797317584 times.
887579952 switch(k)
5363 {
5364 case KEY_F1:
5365 case KEY_F2:
5366 case KEY_F3:
5367 case KEY_F4:
5368 case KEY_F5:
5369 case KEY_F6:
5370 case KEY_F7:
5371 case KEY_F8:
5372 case KEY_F9:
5373 case KEY_F10:
5374 case KEY_F11:
5375 case KEY_F12:
5376 90262368 return true;
5377 }
5378
5379 797317584 return false;
5380 887579952 }
5381
5382 void kb_getkey(DIALOG *d);
5383
5384 //Used by all keyboard key settings dialogues.
5385 void kb_clearjoystick(DIALOG *d)
5386 {
5387 d->flags|=D_SELECTED;
5388
5389 jwin_button_proc(MSG_DRAW,d,0);
5390 jwin_draw_win(gui_bmp, (gui_bmp->w-160)/2, (gui_bmp->h-48)/2, 168, 48, FR_WIN);
5391 // text_mode(vc(11));
5392 textout_centre_ex(gui_bmp, font, "Press any key to clear", gui_bmp->w/2, gui_bmp->h/2 - 8, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5393 textout_centre_ex(gui_bmp, font, "ESC to cancel", gui_bmp->w/2, gui_bmp->h/2, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5394
5395 update_hw_screen(true);
5396
5397 clear_keybuf();
5398 int32_t k = next_press_key();
5399 clear_keybuf();
5400
5401 //shnarf
5402 //47=f1
5403 //59=esc
5404 // if(k>0 && k<123 && !((k>46)&&(k<60)))
5405 // *((int32_t*)d->dp3) = k;
5406 if ( k != 59 ) *((int32_t*)d->dp3) = 0;
5407
5408
5409 d->flags&=~D_SELECTED;
5410 }
5411
5412 //Clears key to 0.
5413 //Used by all keyboard key settings dialogues.
5414 void kb_clearkey(DIALOG *d);
5415
5416 int32_t d_j_clearbutton_proc(int32_t msg,DIALOG *d,int32_t c)
5417 {
5418 switch(msg)
5419 {
5420 case MSG_KEY:
5421 case MSG_CLICK:
5422
5423 kb_clearjoystick(d);
5424
5425 while(gui_mouse_b())
5426 {
5427 clear_keybuf();
5428 rest(1);
5429 }
5430
5431 return D_REDRAW;
5432 }
5433
5434 return jwin_button_proc(msg,d,c);
5435 }
5436
5437 int32_t d_kbutton_proc(int32_t msg,DIALOG *d,int32_t c);
5438 //Only used in keyboard settings dialogues to clear keys.
5439 int32_t d_k_clearbutton_proc(int32_t msg,DIALOG *d,int32_t c);
5440
5441 void j_getbtn(DIALOG *d)
5442 {
5443 d->flags|=D_SELECTED;
5444 jwin_button_proc(MSG_DRAW,d,0);
5445 jwin_draw_win(gui_bmp, (gui_bmp->w-160)/2, (gui_bmp->h-48)/2, 160, 48, FR_WIN);
5446 // text_mode(vc(11));
5447 int32_t y = gui_bmp->h/2 - 12;
5448 textout_centre_ex(gui_bmp, font, "Press a button", gui_bmp->w/2, y, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5449 textout_centre_ex(gui_bmp, font, "ESC to cancel", gui_bmp->w/2, y+8, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5450 textout_centre_ex(gui_bmp, font, "SPACE to disable", gui_bmp->w/2, y+16, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5451
5452 update_hw_screen(true);
5453
5454 int32_t b = next_press_btn();
5455
5456 if(b>=0)
5457 *((int32_t*)d->dp3) = b;
5458
5459 d->flags&=~D_SELECTED;
5460
5461 if (player)
5462 player->joy_on = TRUE;
5463 }
5464
5465 int32_t d_jbutton_proc(int32_t msg,DIALOG *d,int32_t c)
5466 {
5467 switch(msg)
5468 {
5469 case MSG_KEY:
5470 case MSG_CLICK:
5471
5472 j_getbtn(d);
5473
5474 while(gui_mouse_b()) {
5475 rest(1);
5476 clear_keybuf();
5477 }
5478
5479 return D_REDRAW;
5480 }
5481
5482 return jwin_button_proc(msg,d,c);
5483 }
5484
5485 //shnarf
5486 extern const char *key_str[];
5487 std::string get_keystr(int key);
5488
5489 const char *pan_str[4] = { "MONO", " 1/2", " 3/4", "FULL" };
5490 //extern int32_t zcmusic_bufsz;
5491
5492 static char str_a[80],str_b[80],str_s[80],str_m[80],str_l[80],str_r[80],str_p[80],str_ex1[80],str_ex2[80],str_ex3[80],str_ex4[80],
5493 str_leftmod1[80],str_leftmod2[80],str_rightmod1[80],str_rightmod2[80], str_left[80], str_right[80], str_up[80], str_down[80];
5494
5495 int32_t d_stringloader(int32_t msg,DIALOG *d,int32_t c)
5496 {
5497 //these are here to bypass compiler warnings about unused arguments
5498 c=c;
5499
5500 if(msg==MSG_DRAW)
5501 {
5502 switch(d->w)
5503 {
5504 case 0:
5505 sprintf(str_a,"%03d\n%s",Akey,key_str[Akey]);
5506 sprintf(str_b,"%03d\n%s",Bkey,key_str[Bkey]);
5507 sprintf(str_s,"%03d\n%s",Skey,key_str[Skey]);
5508 sprintf(str_l,"%03d\n%s",Lkey,key_str[Lkey]);
5509 sprintf(str_r,"%03d\n%s",Rkey,key_str[Rkey]);
5510 sprintf(str_p,"%03d\n%s",Pkey,key_str[Pkey]);
5511 sprintf(str_ex1,"%03d\n%s",Exkey1,key_str[Exkey1]);
5512 sprintf(str_ex2,"%03d\n%s",Exkey2,key_str[Exkey2]);
5513 sprintf(str_ex3,"%03d\n%s",Exkey3,key_str[Exkey3]);
5514 sprintf(str_ex4,"%03d\n%s",Exkey4,key_str[Exkey4]);
5515 sprintf(str_up,"%03d\n%s",DUkey,key_str[DUkey]);
5516 sprintf(str_down,"%03d\n%s",DDkey,key_str[DDkey]);
5517 sprintf(str_left,"%03d\n%s",DLkey,key_str[DLkey]);
5518 sprintf(str_right,"%03d\n%s",DRkey,key_str[DRkey]);
5519 sprintf(str_leftmod1,"%03d\n%s",cheat_modifier_keys[0],key_str[cheat_modifier_keys[0]]);
5520 sprintf(str_leftmod2,"%03d\n%s",cheat_modifier_keys[1],key_str[cheat_modifier_keys[1]]);
5521 sprintf(str_rightmod1,"%03d\n%s",cheat_modifier_keys[2],key_str[cheat_modifier_keys[2]]);
5522 sprintf(str_rightmod2,"%03d\n%s",cheat_modifier_keys[3],key_str[cheat_modifier_keys[3]]);
5523 break;
5524
5525 case 1:
5526 sprintf(str_a,"%03d\n%s",Abtn,joybtn_name(Abtn));
5527 sprintf(str_b,"%03d\n%s",Bbtn,joybtn_name(Bbtn));
5528 sprintf(str_s,"%03d\n%s",Sbtn,joybtn_name(Sbtn));
5529 sprintf(str_l,"%03d\n%s",Lbtn,joybtn_name(Lbtn));
5530 sprintf(str_r,"%03d\n%s",Rbtn,joybtn_name(Rbtn));
5531 sprintf(str_m,"%03d\n%s",Mbtn,joybtn_name(Mbtn));
5532 sprintf(str_p,"%03d\n%s",Pbtn,joybtn_name(Pbtn));
5533 sprintf(str_ex1,"%03d\n%s",Exbtn1,joybtn_name(Exbtn1));
5534 sprintf(str_ex2,"%03d\n%s",Exbtn2,joybtn_name(Exbtn2));
5535 sprintf(str_ex3,"%03d\n%s",Exbtn3,joybtn_name(Exbtn3));
5536 sprintf(str_ex4,"%03d\n%s",Exbtn4,joybtn_name(Exbtn4));
5537 sprintf(str_up,"%03d\n%s",DUbtn,joybtn_name(DUbtn));
5538 sprintf(str_down,"%03d\n%s",DDbtn,joybtn_name(DDbtn));
5539 sprintf(str_left,"%03d\n%s",DLbtn,joybtn_name(DLbtn));
5540 sprintf(str_right,"%03d\n%s",DRbtn,joybtn_name(DRbtn));
5541 sprintf(str_leftmod1,"%03d\n%s",cheat_modifier_keys[0],key_str[cheat_modifier_keys[0]]);
5542 sprintf(str_leftmod2,"%03d\n%s",cheat_modifier_keys[1],key_str[cheat_modifier_keys[1]]);
5543 sprintf(str_rightmod1,"%03d\n%s",cheat_modifier_keys[2],key_str[cheat_modifier_keys[2]]);
5544 sprintf(str_rightmod2,"%03d\n%s",cheat_modifier_keys[3],key_str[cheat_modifier_keys[3]]);
5545 break;
5546
5547 case 2:
5548 sprintf(str_a," %3d",midi_volume);
5549 sprintf(str_b," %3d",digi_volume);
5550 sprintf(str_l," %3d",emusic_volume);
5551 sprintf(str_m," %3dKB",zcmusic_bufsz);
5552 sprintf(str_r," %3d",sfx_volume);
5553 strcpy(str_s,pan_str[pan_style]);
5554 sprintf(str_leftmod1,"%3d\n%s",cheat_modifier_keys[0],key_str[cheat_modifier_keys[0]]);
5555 sprintf(str_leftmod2,"%3d\n%s",cheat_modifier_keys[1],key_str[cheat_modifier_keys[1]]);
5556 sprintf(str_rightmod1,"%3d\n%s",cheat_modifier_keys[2],key_str[cheat_modifier_keys[2]]);
5557 sprintf(str_rightmod2,"%3d\n%s",cheat_modifier_keys[3],key_str[cheat_modifier_keys[3]]);
5558 break;
5559 }
5560 }
5561
5562 return D_O_K;
5563 }
5564
5565 int32_t set_vol(void *dp3, int32_t d2)
5566 {
5567 switch(((int32_t*)dp3)[0])
5568 {
5569 case 0:
5570 midi_volume = zc_min(d2<<3,255);
5571 break;
5572
5573 case 1:
5574 digi_volume = zc_min(d2<<3,255);
5575 break;
5576
5577 case 2:
5578 emusic_volume = zc_min(d2<<3,255);
5579 break;
5580
5581 case 3:
5582 sfx_volume = zc_min(d2<<3,255);
5583 break;
5584 }
5585
5586 // text_mode(vc(11));
5587 textprintf_right_ex(screen,get_zc_font(font_lfont_l), ((int32_t*)dp3)[1],((int32_t*)dp3)[2],jwin_pal[jcBOXFG],jwin_pal[jcBOX],"%3d",zc_min(d2<<3,255));
5588 return D_O_K;
5589 }
5590
5591 int32_t set_pan(void *dp3, int32_t d2)
5592 {
5593 pan_style = vbound(d2,0,3);
5594 // text_mode(vc(11));
5595 textout_right_ex(screen,get_zc_font(font_lfont_l), pan_str[pan_style],((int32_t*)dp3)[1],((int32_t*)dp3)[2],jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5596 return D_O_K;
5597 }
5598
5599 int32_t set_buf(void *dp3, int32_t d2)
5600 {
5601 // text_mode(vc(11));
5602 zcmusic_bufsz = d2 + 1;
5603 textprintf_right_ex(screen,get_zc_font(font_lfont_l), ((int32_t*)dp3)[1],((int32_t*)dp3)[2],jwin_pal[jcBOXFG],jwin_pal[jcBOX],"%3dKB",zcmusic_bufsz);
5604 return D_O_K;
5605 }
5606
5607 static int32_t gamepad_btn_list[] =
5608 {
5609 6,
5610 7,8,9,10,11,12,13,14,15,16,17,
5611 18,19,20,21,22,23,24,25,26,27,28,
5612 29,30,31,32,33,34,35,36,37,38,39,
5613 -1
5614 };
5615
5616 static int32_t gamepad_dirs_list[] =
5617 {
5618 40,41,42,43,
5619 44,45,46,47,
5620 48,49,50,51,
5621 52,53,54,55,
5622 56,
5623 -1
5624 };
5625
5626 static TABPANEL gamepad_tabs[] =
5627 {
5628 // (text)
5629 { (char *)"Buttons", D_SELECTED, gamepad_btn_list, 0, NULL },
5630 { (char *)"Directions", 0, gamepad_dirs_list, 0, NULL },
5631 { NULL, 0, NULL, 0, NULL }
5632 };
5633
5634 static DIALOG gamepad_dlg[] =
5635 {
5636 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3)
5637 { jwin_win_proc, 8, 24, 304, 256, 0, 0, 0, D_EXIT, 0, 0, (void *) "Gamepad Controls", NULL, NULL },
5638 { jwin_tab_proc, 8+4, 24+23,304-8,256-52,vc(0), vc(15), 0, 0, 0, 0, (void *) gamepad_tabs, NULL, (void *)gamepad_dlg },
5639 { d_stringloader, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5640 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5641 { jwin_button_proc, 90, 254, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
5642 { jwin_button_proc, 170, 254, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
5643 // 6
5644 { d_dummy_proc, 14, 61, 294, 192, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5645 // 7
5646 { jwin_ctext_proc, 92, 92-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_a, NULL, NULL },
5647 { jwin_ctext_proc, 92, 120-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_b, NULL, NULL },
5648 { jwin_ctext_proc, 92, 148-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_s, NULL, NULL },
5649 { jwin_ctext_proc, 92, 180-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex1, NULL, NULL },
5650 { jwin_ctext_proc, 92, 212-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex3, NULL, NULL },
5651 { jwin_ctext_proc, 237, 92-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_l, NULL, NULL },
5652 { jwin_ctext_proc, 237, 120-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_r, NULL, NULL },
5653 { jwin_ctext_proc, 237, 148-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_p, NULL, NULL },
5654 { jwin_ctext_proc, 237, 180-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex2, NULL, NULL },
5655 { jwin_ctext_proc, 237, 212-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex4, NULL, NULL },
5656 { jwin_ctext_proc, 92, 244-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_m, NULL, NULL },
5657 // 18
5658 { d_jbutton_proc, 22, 90-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "A", NULL, &Abtn},
5659 { d_jbutton_proc, 22, 118-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "B", NULL, &Bbtn},
5660 { d_jbutton_proc, 22, 146-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Start", NULL, &Sbtn},
5661 { d_jbutton_proc, 22, 178-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "X (EX1)", NULL, &Exbtn1},
5662 { d_jbutton_proc, 22, 210-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "EX3", NULL, &Exbtn3},
5663 { d_jbutton_proc, 167, 90-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "L", NULL, &Lbtn},
5664 { d_jbutton_proc, 167, 118-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "R", NULL, &Rbtn},
5665 { d_jbutton_proc, 167, 146-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Map", NULL, &Pbtn},
5666 { d_jbutton_proc, 167, 178-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Y (EX2)", NULL, &Exbtn2},
5667 { d_jbutton_proc, 167, 210-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "EX4", NULL, &Exbtn4},
5668 { d_jbutton_proc, 22, 242-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Menu", NULL, &Mbtn},
5669 // 29
5670 { d_j_clearbutton_proc, 22+91, 90-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Abtn},
5671 { d_j_clearbutton_proc, 22+91, 118-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Bbtn},
5672 { d_j_clearbutton_proc, 22+91, 146-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Sbtn},
5673 { d_j_clearbutton_proc, 22+91, 178-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exbtn1},
5674 { d_j_clearbutton_proc, 22+91, 210-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exbtn3},
5675 { d_j_clearbutton_proc, 167+91, 90-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Lbtn},
5676 { d_j_clearbutton_proc, 167+91, 118-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Rbtn},
5677 { d_j_clearbutton_proc, 167+91, 146-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Pbtn},
5678 { d_j_clearbutton_proc, 167+91, 178-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exbtn2},
5679 { d_j_clearbutton_proc, 167+91, 210-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exbtn4},
5680 { d_j_clearbutton_proc, 22+91, 242-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Mbtn},
5681 // 40
5682 { jwin_frame_proc, 14, 62, 147, 80, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5683 { jwin_frame_proc, 159, 62, 147, 80, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5684 { jwin_text_proc, 30, 68, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Vertical", NULL, NULL },
5685 { jwin_text_proc, 175, 68, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Horizontal", NULL, NULL },
5686 // 44
5687 { jwin_text_proc, 92, 84, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_up, NULL, NULL },
5688 { jwin_text_proc, 92, 112, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_down, NULL, NULL },
5689 { jwin_text_proc, 237, 84, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_left, NULL, NULL },
5690 { jwin_text_proc, 237, 112, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_right, NULL, NULL },
5691 // 48
5692 { d_jbutton_proc, 22, 82, 61, 21, vc(14), vc(11), 0, 0, 0, 0, (void *) "Up", NULL, &DUbtn },
5693 { d_jbutton_proc, 22, 110, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Down", NULL, &DDbtn },
5694 { d_jbutton_proc, 167, 82, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Left", NULL, &DLbtn },
5695 { d_jbutton_proc, 167, 110, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Right", NULL, &DRbtn },
5696 // 52
5697 { d_j_clearbutton_proc, 22+91, 82, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DUbtn},
5698 { d_j_clearbutton_proc, 22+91, 110, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DDbtn},
5699 { d_j_clearbutton_proc, 167+91, 82, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DLbtn},
5700 { d_j_clearbutton_proc, 167+91, 110, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DRbtn},
5701 // 56
5702 { jwin_check_proc, 22, 150, 147, 8, vc(14), vc(1), 0, 0, 1, 0, (void *) "Use Analog Stick/DPad", NULL, NULL },
5703 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
5704 };
5705
5706 static int32_t keyboard_keys_list[] =
5707 {
5708 6,7,8,9,10,
5709 11,12,13,14,15,16,17,18,19,20,
5710 21,22,23,24,25,26,27,28,29,30,
5711 31,32,33,34,35,36,37,38,39,40,
5712 -1
5713 };
5714
5715 static int32_t keyboard_dirs_list[] =
5716 {
5717 41,42,43,44,
5718 45,46,47,48,
5719 49,50,51,52,
5720 53,54,55,56,
5721 -1
5722 };
5723
5724 static int32_t keyboard_mods_list[] =
5725 {
5726 57,58,59,60,
5727 61,62,63,64,
5728 65,66,67,68,
5729 69,70,71,72,
5730 -1
5731 };
5732
5733 static TABPANEL keyboard_control_tabs[] =
5734 {
5735 // (text)
5736 { (char *)"Keys", D_SELECTED, keyboard_keys_list, 0, NULL },
5737 { (char *)"Directions", 0, keyboard_dirs_list, 0, NULL },
5738 { (char *)"Cheat Mods", 0, keyboard_mods_list, 0, NULL },
5739 { NULL, 0, NULL, 0, NULL }
5740 };
5741
5742 static DIALOG keyboard_control_dlg[] =
5743 {
5744 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3)
5745 { jwin_win_proc, 8, 39, 304, 240, 0, 0, 0, D_EXIT, 0, 0, (void *) "Keyboard Controls", NULL, NULL },
5746 { jwin_tab_proc, 8+4, 39+23,304-8,240-56,vc(0), vc(15), 0, 0, 0, 0, (void *) keyboard_control_tabs, NULL, (void *)keyboard_control_dlg },
5747 { d_stringloader, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5748 { jwin_button_proc, 90, 254, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
5749 { jwin_button_proc, 170, 254, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
5750 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5751 // Keys
5752 // 6
5753 { jwin_frame_proc, 14, 80, 148, 105, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5754 { jwin_frame_proc, 158, 80, 148, 105, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5755 { jwin_frame_proc, 14, 181, 292, 67, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5756 { jwin_text_proc, 30, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Standard", NULL, NULL },
5757 { jwin_text_proc, 175, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Extended", NULL, NULL },
5758 // 11
5759 { jwin_text_proc, 92-4, 102, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_a, NULL, NULL },
5760 { jwin_text_proc, 92-4, 130, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_b, NULL, NULL },
5761 { jwin_text_proc, 92-4, 158, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_s, NULL, NULL },
5762 { jwin_text_proc, 92-4, 190, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex1, NULL, NULL },
5763 { jwin_text_proc, 92-4, 222, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex3, NULL, NULL },
5764 { jwin_text_proc, 237-4, 102, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_l, NULL, NULL },
5765 { jwin_text_proc, 237-4, 130, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_r, NULL, NULL },
5766 { jwin_text_proc, 237-4, 158, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_p, NULL, NULL },
5767 { jwin_text_proc, 237-4, 190, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex2, NULL, NULL },
5768 { jwin_text_proc, 237-4, 222, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex4, NULL, NULL },
5769 // 21
5770 { d_kbutton_proc, 22, 100, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "A", NULL, &Akey},
5771 { d_kbutton_proc, 22, 128, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "B", NULL, &Bkey},
5772 { d_kbutton_proc, 22, 156, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Start", NULL, &Skey},
5773 { d_kbutton_proc, 22, 188, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "X (EX1)", NULL, &Exkey1},
5774 { d_kbutton_proc, 22, 220, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "EX3", NULL, &Exkey3},
5775 { d_kbutton_proc, 167, 100, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "L", NULL, &Lkey},
5776 { d_kbutton_proc, 167, 128, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "R", NULL, &Rkey},
5777 { d_kbutton_proc, 167, 156, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Map", NULL, &Pkey},
5778 { d_kbutton_proc, 167, 188, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Y (EX2)", NULL, &Exkey2},
5779 { d_kbutton_proc, 167, 220, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "EX4", NULL, &Exkey4},
5780 // 31
5781 { d_k_clearbutton_proc, 22+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Akey},
5782 { d_k_clearbutton_proc, 22+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Bkey},
5783 { d_k_clearbutton_proc, 22+91, 156, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Skey},
5784 { d_k_clearbutton_proc, 22+91, 188, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exkey1},
5785 { d_k_clearbutton_proc, 22+91, 220, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exkey3},
5786 { d_k_clearbutton_proc, 167+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Lkey},
5787 { d_k_clearbutton_proc, 167+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Rkey},
5788 { d_k_clearbutton_proc, 167+91, 156, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Pkey},
5789 { d_k_clearbutton_proc, 167+91, 188, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exkey2},
5790 { d_k_clearbutton_proc, 167+91, 220, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exkey4},
5791 // Dirs
5792 // 41
5793 { jwin_frame_proc, 14, 80, 147, 80, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5794 { jwin_frame_proc, 159, 80, 147, 80, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5795 { jwin_text_proc, 30, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Vertical", NULL, NULL },
5796 { jwin_text_proc, 175, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Horizontal", NULL, NULL },
5797 // 45
5798 { jwin_text_proc, 92-4, 102, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_up, NULL, NULL },
5799 { jwin_text_proc, 92-4, 130, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_down, NULL, NULL },
5800 { jwin_text_proc, 237-4, 102, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_left, NULL, NULL },
5801 { jwin_text_proc, 237-4, 130, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_right, NULL, NULL },
5802 // 49
5803 { d_kbutton_proc, 22, 100, 61, 21, vc(14), vc(11), 0, 0, 0, 0, (void *) "Up", NULL, &DUkey},
5804 { d_kbutton_proc, 22, 128, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Down", NULL, &DDkey},
5805 { d_kbutton_proc, 167, 100, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Left", NULL, &DLkey},
5806 { d_kbutton_proc, 167, 128, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Right", NULL, &DRkey},
5807 // 53
5808 { d_k_clearbutton_proc, 22+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DUkey},
5809 { d_k_clearbutton_proc, 22+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DDkey},
5810 { d_k_clearbutton_proc, 167+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DLkey},
5811 { d_k_clearbutton_proc, 167+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DRkey},
5812 // Mods
5813 // 57
5814 { jwin_frame_proc, 14, 80, 148, 140-58, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5815 { jwin_frame_proc, 158, 80, 148, 140-58, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5816 { jwin_text_proc, 30, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Left", NULL, NULL },
5817 { jwin_text_proc, 175, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Right", NULL, NULL },
5818 // 61
5819 { jwin_text_proc, 92-26, 101, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_leftmod1, NULL, NULL },
5820 { jwin_text_proc, 92-26, 129, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_rightmod1, NULL, NULL },
5821 { jwin_text_proc, 237-4-22,101, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_leftmod2, NULL, NULL },
5822 { jwin_text_proc, 237-4-22,129, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_rightmod2, NULL, NULL },
5823 // 65
5824 { d_kbutton_proc, 22, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Main", NULL, &cheat_modifier_keys[0]},
5825 { d_kbutton_proc, 22, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Second", NULL, &cheat_modifier_keys[2]},
5826 { d_kbutton_proc, 167, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Main", NULL, &cheat_modifier_keys[1]},
5827 { d_kbutton_proc, 167, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Second", NULL, &cheat_modifier_keys[3]},
5828 // 69
5829 { d_k_clearbutton_proc, 22+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &cheat_modifier_keys[0]},
5830 { d_k_clearbutton_proc, 22+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &cheat_modifier_keys[2]},
5831 { d_k_clearbutton_proc, 167+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &cheat_modifier_keys[1]},
5832 { d_k_clearbutton_proc, 167+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &cheat_modifier_keys[3]},
5833 // 73
5834 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
5835 };
5836
5837 /*
5838 int32_t midi_dp[3] = {0,147,104};
5839 int32_t digi_dp[3] = {1,147,120};
5840 int32_t pan_dp[3] = {0,147,136};
5841 int32_t buf_dp[3] = {0,147,152};
5842 */
5843 int32_t midi_dp[3] = {0,0,0};
5844 int32_t digi_dp[3] = {1,0,0};
5845 int32_t emus_dp[3] = {2,0,0};
5846 int32_t buf_dp[3] = {0,0,0};
5847 int32_t sfx_dp[3] = {3,0,0};
5848 int32_t pan_dp[3] = {0,0,0};
5849
5850 static DIALOG sound_dlg[] =
5851 {
5852 //(dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3)
5853 31 { jwin_win_proc, 0, 0, 320, 178, 0, 0, 0, D_EXIT, 0, 0, (void *) "Sound Settings", NULL, NULL },
5854 31 { d_stringloader, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5855 31 { jwin_button_proc, 58, 148, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
5856 31 { jwin_button_proc, 138, 148, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
5857 31 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5858 31 { jwin_frame_proc, 10, 28, 300, 112, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
5859 31 { jwin_rtext_proc, 190, 40, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_a, NULL, NULL },
5860 31 { jwin_rtext_proc, 190, 56, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_b, NULL, NULL },
5861 31 { jwin_rtext_proc, 190, 72, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_l, NULL, NULL },
5862 31 { jwin_rtext_proc, 190, 88, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_m, NULL, NULL },
5863 // 10
5864 31 { jwin_rtext_proc, 190, 104, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_r, NULL, NULL },
5865 31 { jwin_rtext_proc, 190, 120, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_s, NULL, NULL },
5866 31 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5867 31 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5868 31 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5869 31 { jwin_slider_proc, 196, 40, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 32, 0, NULL, (void *) set_vol, midi_dp },
5870 31 { jwin_slider_proc, 196, 56, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 32, 0, NULL, (void *) set_vol, digi_dp },
5871 31 { jwin_slider_proc, 196, 72, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 32, 0, NULL, (void *) set_vol, emus_dp },
5872 31 { jwin_slider_proc, 196, 88, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 127, 0, NULL, (void *) set_buf, buf_dp },
5873 31 { jwin_slider_proc, 196, 104, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 32, 0, NULL, (void *) set_vol, sfx_dp },
5874 //20
5875 31 { jwin_slider_proc, 196, 120, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 3, 0, NULL, (void *) set_pan, pan_dp },
5876 31 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5877 31 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5878 31 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5879 31 { jwin_text_proc, 17, 40, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Master MIDI Volume", NULL, NULL },
5880 31 { jwin_text_proc, 17, 56, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Master Digi Volume", NULL, NULL },
5881 31 { jwin_text_proc, 17, 72, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Enhanced Music Volume", NULL, NULL },
5882 31 { jwin_text_proc, 17, 88, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Enhanced Music Buffer", NULL, NULL },
5883 31 { jwin_text_proc, 17, 104, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "SFX Volume", NULL, NULL },
5884 31 { jwin_text_proc, 17, 120, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "SFX Pan", NULL, NULL },
5885 //30
5886 31 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5887 31 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5888 31 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5889 31 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5890 };
5891
5892 char zc_builddate[80];
5893 char zc_aboutstr[80];
5894
5895 static DIALOG about_dlg[] =
5896 {
5897 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
5898 { jwin_win_proc, 68, 52, 184, 154, 0, 0, 0, D_EXIT, 0, 0, (void *) "About", NULL, NULL },
5899 { jwin_button_proc, 140, 176, 41, 21, vc(14), 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
5900 { jwin_ctext_proc, 160, 84, 0, 8, vc(0), vc(11), 0, 0, 0, 0, zc_aboutstr, NULL, NULL },
5901 { jwin_ctext_proc, 160, 92, 0, 8, vc(0) , vc(11), 0, 0, 0, 0, str_s, NULL, NULL },
5902 { jwin_ctext_proc, 160, 100, 0, 8, vc(0) , vc(11), 0, 0, 0, 0, zc_builddate, NULL, NULL },
5903 { jwin_text_proc, 88, 124, 140, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Coded by:", NULL, NULL },
5904 { jwin_text_proc, 88, 132, 140, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) " Phantom Menace", NULL, NULL },
5905 { jwin_text_proc, 88, 144, 140, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Produced by:", NULL, NULL },
5906 { jwin_text_proc, 88, 152, 140, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) " Armageddon Games", NULL, NULL },
5907 { jwin_frame_proc, 80, 117, 160, 50, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5908 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5909 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
5910 };
5911
5912
5913 static DIALOG quest_dlg[] =
5914 {
5915 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
5916 { jwin_win_proc, 68, 25, 184, 190, 0, 0, 0, D_EXIT, 0, 0, (void *) "Quest Info", NULL, NULL },
5917 { jwin_edit_proc, 84, 54, 152, 16, 0, 0, 0, D_READONLY, 100, 0, NULL, NULL, NULL },
5918 { jwin_text_proc, 89, 84, 141, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Number:", NULL, NULL },
5919 { jwin_text_proc, 152, 84, 24, 8, vc(7), vc(11), 0, 0, 0, 0, str_a, NULL, NULL },
5920 { jwin_text_proc, 89, 94, 141, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Version:", NULL, NULL },
5921 { jwin_text_proc, 160, 94, 64, 8, vc(7), vc(11), 0, 0, 0, 0, header_version_nul_term, NULL, NULL },
5922 { jwin_text_proc, 89, 104, 141, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "ZQ Version:", NULL, NULL },
5923 { jwin_text_proc, 184, 104, 64, 8, vc(7), vc(11), 0, 0, 0, 0, str_s, NULL, NULL },
5924 { jwin_text_proc, 84, 126, 80, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Title:", NULL, NULL },
5925 { jwin_textbox_proc, 84, 136, 152, 24, 0, 0, 0, 0, 0, 0, QHeader.title, NULL, NULL },
5926 { jwin_text_proc, 84, 168, 80, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Author:", NULL, NULL },
5927 { jwin_textbox_proc, 84, 178, 152, 24, 0, 0, 0, 0, 0, 0, QHeader.author, NULL, NULL },
5928 { jwin_frame_proc, 84, 79, 152, 38, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5929 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5930 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
5931 };
5932
5933 static DIALOG triforce_dlg[] =
5934 {
5935 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) */
5936 { jwin_win_proc, 72, 64, 177, 105, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Triforce Pieces", NULL, NULL },
5937 // 1
5938 { jwin_check_proc, 129, 94, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "1", NULL, NULL },
5939 { jwin_check_proc, 129, 104, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "2", NULL, NULL },
5940 { jwin_check_proc, 129, 114, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "3", NULL, NULL },
5941 { jwin_check_proc, 129, 124, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "4", NULL, NULL },
5942 { jwin_check_proc, 172, 94, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "5", NULL, NULL },
5943 { jwin_check_proc, 172, 104, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "6", NULL, NULL },
5944 { jwin_check_proc, 172, 114, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "7", NULL, NULL },
5945 { jwin_check_proc, 172, 124, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "8", NULL, NULL },
5946 // 9
5947 { jwin_button_proc, 90, 144, 61, 21, vc(0), vc(11), 'k', D_EXIT, 0, 0, (void *) "O&K", NULL, NULL },
5948 { jwin_button_proc, 170, 144, 61, 21, vc(0), vc(11), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
5949 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5950 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
5951 };
5952
5953 bool zc_getname(const char *prompt,const char *ext,EXT_LIST *list,const char *def,bool usefilename)
5954 {
5955 go();
5956 int32_t ret=0;
5957 ret = zc_getname_nogo(prompt,ext,list,def,usefilename);
5958 comeback();
5959 return ret != 0;
5960 }
5961
5962
5963 bool zc_getname_nogo(const char *prompt,const char *ext,EXT_LIST *list,const char *def,bool usefilename)
5964 {
5965 if(def!=modulepath)
5966 strcpy(modulepath,def);
5967
5968 if(!usefilename)
5969 {
5970 int32_t i=(int32_t)strlen(modulepath);
5971
5972 while(i>=0 && modulepath[i]!='\\' && modulepath[i]!='/')
5973 modulepath[i--]=0;
5974 }
5975
5976 // int32_t ret = file_select_ex(prompt,modulepath,ext,255,-1,-1);
5977 int32_t ret=0;
5978 int32_t sel=0;
5979
5980 if(list==NULL)
5981 {
5982 ret = jwin_file_select_ex(prompt,modulepath,ext,2048,-1,-1,get_zc_font(font_lfont));
5983 }
5984 else
5985 {
5986 ret = jwin_file_browse_ex(prompt, modulepath, list, &sel, 2048, -1, -1, get_zc_font(font_lfont));
5987 }
5988
5989 return ret!=0;
5990 }
5991
5992 //The Dialogue that loads a ZMOD Module File
5993 int32_t zc_load_zmod_module_file()
5994 {
5995 if ( Playing )
5996 {
5997 jwin_alert("Error","Cannot change module while playing a quest!",NULL,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont));
5998 return -1;
5999 }
6000 if(!zc_getname("Load Module (.zmod)","zmod",NULL,modulepath,false))
6001 return D_CLOSE;
6002
6003 FILE *tempmodule = fopen(modulepath,"r");
6004
6005 if(tempmodule == NULL)
6006 {
6007 jwin_alert("Error","Cannot open specified file!",NULL,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont));
6008 return -1;
6009 }
6010
6011
6012 //Set the module path:
6013 memset(moduledata.module_name, 0, sizeof(moduledata.module_name));
6014 strcpy(moduledata.module_name, modulepath);
6015 al_trace("New Module Path is: %s \n", moduledata.module_name);
6016 zc_set_config("ZCMODULE","current_module",moduledata.module_name);
6017 zcm.init(true); //Load the module values.
6018 moduledata.refresh_title_screen = 1;
6019 // refresh_select_screen = 1;
6020 build_biic_list();
6021 return D_O_K;
6022 }
6023
6024 static DIALOG module_info_dlg[] =
6025 {
6026 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp)
6027
6028
6029 { jwin_win_proc, 0, 0, 200, 200, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "About Current Module", NULL, NULL },
6030 //1
6031 { jwin_text_proc, 10, 20, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"Module:", NULL, NULL },
6032 //2
6033 { jwin_text_proc, 50, 20, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6034 { jwin_text_proc, 10, 30, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"Author:", NULL, NULL },
6035 //4
6036 { jwin_text_proc, 50, 30, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6037 { jwin_text_proc, 10, 40, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6038 { jwin_text_proc, 10, 50, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"Information:", NULL, NULL },
6039 //7
6040
6041 { jwin_text_proc, 10, 60, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6042 { jwin_text_proc, 10, 70, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6043 { jwin_text_proc, 10, 80, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6044 { jwin_text_proc, 10, 90, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6045 { jwin_text_proc, 10, 100, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6046 { jwin_text_proc, 10, 120, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6047 { jwin_text_proc, 10, 130, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6048 { jwin_text_proc, 10, 140, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6049 { jwin_text_proc, 10, 150, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6050
6051 { jwin_button_proc, 40, 160, 50, 21, vc(14), vc(1), 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
6052 { jwin_button_proc, 200-40-50, 160, 50, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
6053 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6054 };
6055
6056 void about_zcplayer_module(const char *prompt,int32_t initialval)
6057 {
6058
6059 module_info_dlg[0].dp2 = get_zc_font(font_lfont);
6060 if ( moduledata.moduletitle[0] != 0 )
6061 module_info_dlg[2].dp = (char*)moduledata.moduletitle;
6062
6063 if ( moduledata.moduleauthor[0] != 0 )
6064 module_info_dlg[4].dp = (char*)moduledata.moduleauthor;
6065
6066 if ( moduledata.moduleinfo0[0] != 0 )
6067 module_info_dlg[7].dp = (char*)moduledata.moduleinfo0;
6068 if ( moduledata.moduleinfo1[0] != 0 )
6069 module_info_dlg[8].dp = (char*)moduledata.moduleinfo1;
6070 if ( moduledata.moduleinfo2[0] != 0 )
6071 module_info_dlg[9].dp = (char*)moduledata.moduleinfo2;
6072 if ( moduledata.moduleinfo3[0] != 0 )
6073 module_info_dlg[10].dp = (char*)moduledata.moduleinfo3;
6074 if ( moduledata.moduleinfo4[0] != 0 )
6075 module_info_dlg[11].dp = (char*)moduledata.moduleinfo4;
6076
6077 char module_date[255];
6078 memset(module_date, 0, sizeof(module_date));
6079 sprintf(module_date,"Build Date: %s %s, %d at @ %d:%d %s", dayextension(moduledata.modday).c_str(),
6080 (char*)months[moduledata.modmonth], moduledata.modyear, moduledata.modhour, moduledata.modminute, moduledata.moduletimezone);
6081
6082
6083
6084 char module_vers[255];
6085 memset(module_vers, 0, sizeof(module_vers));
6086 sprintf(module_vers, "Version: %d.%d.%d.%d", moduledata.modver_1, moduledata.modver_2, moduledata.modver_3, moduledata.modver_4);
6087
6088
6089 //sprintf(tilecount,"%d",1);
6090
6091 char module_build[255];
6092 memset(module_build, 0, sizeof(module_build));
6093 if ( moduledata.modbeta )
6094 sprintf(module_build,"Module Build: %d, %s: %d", moduledata.modbuild, (moduledata.modbeta<0) ? "Alpha" : "Beta", moduledata.modbeta );
6095 else
6096 sprintf(module_build,"Module Build: %d", moduledata.modbuild);
6097
6098 module_info_dlg[12].dp = (char*)module_date;
6099 module_info_dlg[13].dp = (char*)module_vers;
6100 module_info_dlg[14].dp = (char*)module_build;
6101
6102 large_dialog(module_info_dlg);
6103
6104 int32_t ret = zc_popup_dialog(module_info_dlg,-1);
6105 jwin_center_dialog(module_info_dlg);
6106
6107
6108 }
6109
6110 int32_t onAbout_ZCP_Module()
6111 {
6112 about_zcplayer_module("About Module (.zmod)", 0);
6113 return D_O_K;
6114 }
6115
6116 //New Modules Menu for 2.55+
6117 static MENU zcmodule_menu[] =
6118 {
6119 { (char *)"&Load Module...", zc_load_zmod_module_file, NULL, 0, NULL },
6120 { (char *)"&About Module", onAbout_ZCP_Module, NULL, 0, NULL },
6121
6122 { NULL, NULL, NULL, 0, NULL }
6123 };
6124
6125 int32_t onToggleRecordingNewSaves()
6126 {
6127 if (zc_get_config("zeldadx", "replay_new_saves", false))
6128 {
6129 zc_set_config("zeldadx", "replay_new_saves", false);
6130 }
6131 else
6132 {
6133 zc_set_config("zeldadx", "replay_new_saves", true);
6134 jwin_alert("Recording", "Newly created saves will be recorded and written to a replay file.",
6135 NULL,NULL,"OK",NULL,13,27,get_zc_font(font_lfont));
6136 }
6137 return D_O_K;
6138 }
6139
6140 int32_t onToggleSnapshotAllFrames()
6141 {
6142 replay_set_snapshot_all_frames(!replay_is_snapshot_all_frames());
6143 return D_O_K;
6144 }
6145
6146 int32_t onStopReplayOrRecord()
6147 {
6148 if (replay_is_replaying())
6149 {
6150 replay_quit();
6151 }
6152 else if (replay_get_mode() == ReplayMode::Record)
6153 {
6154 if (!replay_get_meta_bool("test_mode"))
6155 {
6156 jwin_alert("Recording", "You cannot stop recording a save file.",
6157 NULL,NULL,"OK",NULL,13,27,get_zc_font(font_lfont));
6158 return D_CLOSE;
6159 }
6160
6161 if (jwin_alert("Stop Recording",
6162 "Save replay to disk and stop recording?",
6163 "This will stop the recording.",
6164 NULL,
6165 "Yes","No",13,27,get_zc_font(font_lfont)) != 1)
6166 return D_CLOSE;
6167
6168 replay_save();
6169 replay_stop();
6170 }
6171 return D_O_K;
6172 }
6173
6174 static int32_t handle_on_load_replay(ReplayMode mode)
6175 {
6176 if (Playing)
6177 {
6178 if (jwin_alert("Replay - Warning!",
6179 "Loading a replay will exit the current game.",
6180 "All unsaved progress will be lost.",
6181 "Do you wish to continue?",
6182 "Yes","No",13,27,get_zc_font(font_lfont)) != 1)
6183 return D_CLOSE;
6184 }
6185
6186 std::string mode_string = replay_mode_to_string(mode);
6187 mode_string[0] = std::toupper(mode_string[0]);
6188
6189 std::string line_1 = "Select a replay file to play back.";
6190 std::string line_2 = "You won't be able to save, and it won't effect existing saves.";
6191 std::string line_3 = "You can stop the replay and take over manually any time.";
6192 if (mode == ReplayMode::Update)
6193 {
6194 line_1 = "Select a replay file to update.";
6195 line_2 = "WARNING: be sure to back up the zplay file";
6196 line_3 = "and verify that the updated replay works as expected!";
6197 }
6198
6199 if (jwin_alert(mode_string.c_str(),
6200 line_1.c_str(),
6201 line_2.c_str(),
6202 line_3.c_str(),
6203 "OK","Nevermind",13,27,get_zc_font(font_lfont)) == 1)
6204 {
6205 char replay_path[2048];
6206 strcpy(replay_path, "replays/");
6207 if (jwin_file_select_ex(
6208 fmt::format("Load Replay (.{})", REPLAY_EXTENSION).c_str(),
6209 replay_path, REPLAY_EXTENSION.c_str(), 2048, -1, -1, get_zc_font(font_lfont)) == 0)
6210 return D_CLOSE;
6211
6212 replay_quit();
6213 load_replay_file_deferred(mode, replay_path);
6214 Quit = qRESET;
6215 return D_CLOSE;
6216 }
6217 return D_O_K;
6218 }
6219
6220 int32_t onLoadReplay()
6221 {
6222 return handle_on_load_replay(ReplayMode::Replay);
6223 }
6224
6225 int32_t onLoadReplayAssert()
6226 {
6227 return handle_on_load_replay(ReplayMode::Assert);
6228 }
6229
6230 int32_t onLoadReplayUpdate()
6231 {
6232 return handle_on_load_replay(ReplayMode::Update);
6233 }
6234
6235 int32_t onSaveReplay()
6236 {
6237 if (replay_get_mode() == ReplayMode::Record)
6238 {
6239 if (!replay_get_meta_bool("test_mode"))
6240 {
6241 if (jwin_alert("Save Replay",
6242 "This will save a copy of the replay up to this point.",
6243 "The official replay file will be untouched.",
6244 "Do you wish to continue?",
6245 "Yes","No",13,27,get_zc_font(font_lfont)) != 1)
6246 return D_CLOSE;
6247
6248 char replay_path[2048];
6249 strcpy(replay_path, replay_get_replay_path().string().c_str());
6250 if (jwin_file_select_ex(
6251 fmt::format("Save Replay (.{})", REPLAY_EXTENSION).c_str(),
6252 replay_path, REPLAY_EXTENSION.c_str(), 2048, -1, -1, get_zc_font(font_lfont)) == 0)
6253 return D_CLOSE;
6254
6255 if (fileexists(replay_path))
6256 {
6257 jwin_alert("Save Replay", "You cannot overwrite an existing file.",
6258 NULL,NULL,"OK",NULL,13,27,get_zc_font(font_lfont));
6259 return D_CLOSE;
6260 }
6261
6262 replay_save(replay_path);
6263 }
6264 else
6265 {
6266 replay_save();
6267 }
6268 }
6269 return D_O_K;
6270 }
6271
6272 static MENU replay_menu[] =
6273 {
6274 { (char *)"Record new saves", onToggleRecordingNewSaves, NULL, 0, NULL },
6275 { (char *)"Stop replay", onStopReplayOrRecord, NULL, 0, NULL },
6276 { (char *)"Load replay", onLoadReplay, NULL, 0, NULL },
6277 { (char *)"Load replay (assert)", onLoadReplayAssert, NULL, 0, NULL },
6278 { (char *)"Load replay (update)", onLoadReplayUpdate, NULL, 0, NULL },
6279 { (char *)"Save replay", onSaveReplay, NULL, 0, NULL },
6280 { (char *)"Enable snapshot all frames", onToggleSnapshotAllFrames,NULL, 0, NULL },
6281
6282 { NULL, NULL, NULL, 0, NULL }
6283 };
6284
6285 static DIALOG credits_dlg[] =
6286 {
6287 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
6288 { jwin_win_proc, 40, 38, 241, 173, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Zelda Classic Credits", NULL, NULL },
6289 { jwin_frame_proc, 47, 65, 227, 115, vc(15), vc(1), 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
6290 { d_bitmap_proc, 49, 67, 222, 110, vc(15), vc(1), 0, 0, 0, 0, NULL, NULL, NULL },
6291 { jwin_button_proc, 140, 184, 41, 21, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
6292 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6293 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6294 };
6295
6296 31 static ListData dmap_list(dmaplist, &font);
6297
6298 static DIALOG goto_dlg[] =
6299 {
6300 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
6301 { jwin_win_proc, 48, 25, 205, 100, 0, 0, 0, D_EXIT, 0, 0, (void *) "Goto Location", NULL, NULL },
6302 { jwin_button_proc, 90, 176-78, 61, 21, vc(14), 0, 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
6303 { jwin_button_proc, 170, 176-78, 61, 21, vc(14), 0, 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
6304 { jwin_text_proc, 55, 129-75, 80, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "DMap:", NULL, NULL },
6305 { jwin_droplist_proc, 88, 126-75, 160, 16, 0, 0, 0, 0, 0, 0, (void *) &dmap_list, NULL, NULL },
6306 { jwin_text_proc, 55, 149-75, 80, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Screen:", NULL, NULL },
6307 { jwin_edit_proc, 132, 146-75, 91, 16, 0, 0, 0, 0, 2, 0, NULL, NULL, NULL },
6308 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6309 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6310 };
6311
6312 int32_t onGoTo()
6313 {
6314 bool music = false;
6315 music = music;
6316 sprintf(cheat_goto_screen_str,"%X",cheat_goto_screen);
6317
6318 goto_dlg[0].dp2=get_zc_font(font_lfont);
6319 goto_dlg[4].d2=cheat_goto_dmap;
6320 goto_dlg[6].dp=cheat_goto_screen_str;
6321
6322 clear_keybuf();
6323
6324 large_dialog(goto_dlg);
6325
6326 if(zc_popup_dialog(goto_dlg,4)==1)
6327 {
6328 // dmap, screen
6329 cheats_enqueue(Cheat::GoTo, goto_dlg[4].d2, zc_min(zc_xtoi(cheat_goto_screen_str),0x7F));
6330 };
6331
6332 return D_O_K;
6333 }
6334
6335 int32_t onGoToComplete()
6336 {
6337 if(!Playing)
6338 {
6339 return D_O_K;
6340 }
6341
6342 system_pal();
6343 music_pause();
6344 pause_all_sfx();
6345 onGoTo();
6346 eat_buttons();
6347
6348 zc_readrawkey(KEY_ESC);
6349
6350 game_pal();
6351 music_resume();
6352 resume_all_sfx();
6353 return D_O_K;
6354 }
6355
6356 int32_t onCredits()
6357 {
6358 go();
6359
6360 BITMAP *win = create_bitmap_ex(8,222,110);
6361
6362 if(!win)
6363 return D_O_K;
6364
6365 int32_t c=0;
6366 int32_t l=0;
6367 int32_t ol=-1;
6368 RLE_SPRITE *rle = (RLE_SPRITE*)(datafile[RLE_CREDITS].dat);
6369 RGB *pal = (RGB*)(datafile[PAL_CREDITS].dat);
6370 PALETTE tmppal;
6371
6372 rti_gui.transparency_index = 1;
6373
6374 clear_to_color(win, rti_gui.transparency_index);
6375 draw_rle_sprite(win,rle,0,0);
6376 credits_dlg[0].dp2=get_zc_font(font_lfont);
6377 credits_dlg[1].fg = jwin_pal[jcDISABLED_FG];
6378 credits_dlg[2].dp = win;
6379
6380 zc_set_palette_range(black_palette,0,127,false);
6381
6382 DIALOG_PLAYER *p = init_dialog(credits_dlg,3);
6383
6384 BITMAP* old_screen = screen;
6385 BITMAP* gui_bmp = zc_get_gui_bmp();
6386 ASSERT(gui_bmp);
6387 clear_to_color(gui_bmp, rti_gui.transparency_index);
6388 screen = gui_bmp;
6389
6390 while(update_dialog(p))
6391 {
6392 throttleFPS();
6393 ++c;
6394 l = zc_max((c>>1)-30,0);
6395
6396 if(l > rle->h)
6397 l = c = 0;
6398
6399 if(l > rle->h - 112)
6400 l = rle->h - 112;
6401
6402 clear_bitmap(win);
6403 draw_rle_sprite(win,rle,0,0-l);
6404
6405 if(c<=64)
6406 fade_interpolate(black_palette,pal,tmppal,c,0,127);
6407
6408 zc_set_palette_range(tmppal,0,127,false);
6409
6410 if(l!=ol)
6411 {
6412 d_bitmap_proc(MSG_DRAW,credits_dlg+2,0);
6413 SCRFIX();
6414 ol=l;
6415 }
6416
6417 update_hw_screen();
6418 }
6419
6420 screen = old_screen;
6421 system_pal();
6422
6423 shutdown_dialog(p);
6424 destroy_bitmap(win);
6425 //comeback();
6426
6427 rti_gui.transparency_index = 0;
6428 clear_to_color(gui_bmp, rti_gui.transparency_index);
6429
6430 return D_O_K;
6431 }
6432
6433 const char *midilist(int32_t index, int32_t *list_size)
6434 {
6435 if(index<0)
6436 {
6437 *list_size=0;
6438
6439 for(int32_t i=0; i<MAXMIDIS; i++)
6440 if(tunes[i].data)
6441 ++(*list_size);
6442
6443 return NULL;
6444 }
6445
6446 int32_t i=0,m=0;
6447
6448 while(m<=index && i<=MAXMIDIS)
6449 {
6450 if(tunes[i].data)
6451 ++m;
6452
6453 ++i;
6454 }
6455
6456 --i;
6457
6458 if(i==MAXMIDIS && m<index)
6459 return "(null)";
6460
6461 return tunes[i].title;
6462 }
6463
6464 /* ------- MIDI info stuff -------- */
6465
6466 char *text;
6467 midi_info *zmi;
6468 bool dialog_running;
6469 bool listening;
6470
6471 void get_info(int32_t index);
6472
6473 int32_t d_midilist_proc(int32_t msg,DIALOG *d,int32_t c)
6474 {
6475 int32_t d2 = d->d2;
6476 int32_t ret = jwin_droplist_proc(msg,d,c);
6477
6478 if(d2!=d->d2)
6479 {
6480 get_info(d->d2);
6481 }
6482
6483 return ret;
6484 }
6485
6486 int32_t d_listen_proc(int32_t msg,DIALOG *d,int32_t c)
6487 {
6488 /* 'd->d1' is offset from 'd' in DIALOG array to midilist proc */
6489
6490 int32_t ret = jwin_button_proc(msg,d,c);
6491
6492 if(ret == D_CLOSE)
6493 {
6494 // get current midi index
6495 int32_t index = (d+(d->d1))->d2;
6496 int32_t i=0, m=0;
6497
6498 while(m<=index && i<=MAXMIDIS)
6499 {
6500 if(tunes[i].data)
6501 ++m;
6502
6503 ++i;
6504 }
6505
6506 --i;
6507 jukebox(i);
6508 listening = true;
6509 ret = D_O_K;
6510 }
6511
6512 return ret;
6513 }
6514
6515 int32_t d_savemidi_proc(int32_t msg,DIALOG *d,int32_t c)
6516 {
6517 /* 'd->d1' is offset from 'd' in DIALOG array to midilist proc */
6518
6519 int32_t ret = jwin_button_proc(msg,d,c);
6520
6521 if(ret == D_CLOSE)
6522 {
6523 // get current midi index
6524 int32_t index = (d+(d->d1))->d2;
6525 int32_t i=0, m=0;
6526
6527 while(m<=index && i<=MAXMIDIS)
6528 {
6529 if(tunes[i].data)
6530 ++m;
6531
6532 ++i;
6533 }
6534
6535 --i;
6536
6537 // get file name
6538
6539 int32_t sel=0;
6540 //struct ffblk f;
6541 char title[40] = "Save MIDI: ";
6542 char fname[2048];
6543 memset(fname,0,2048);
6544 static EXT_LIST list[] =
6545 {
6546 { (char *)"MIDI files (*.mid)", (char *)"mid" },
6547 { (char *)"HTML files (*.html, *.html)", (char *)"htm html" },
6548 { NULL, NULL }
6549 };
6550
6551 strcpy(title+11, tunes[i].title);
6552 title[39] = '\0';
6553
6554 if(jwin_file_browse_ex(title, fname, list, &sel, 2048, -1, -1, get_zc_font(font_lfont))==0)
6555 goto done;
6556
6557 if(exists(fname))
6558 {
6559 if(jwin_alert(title, fname, "already exists.", "Overwrite it?", "&Yes","&No",'y','n',get_zc_font(font_lfont))==2)
6560 goto done;
6561 }
6562
6563 // save midi i
6564
6565 if(save_midi(fname, (MIDI*)tunes[i].data) != 0)
6566 jwin_alert(title, "Error saving MIDI to", fname, NULL, "Darn", NULL,13,27,get_zc_font(font_lfont));
6567
6568 done:
6569 chop_path(fname);
6570 ret = D_REDRAW;
6571 }
6572
6573 return ret;
6574 }
6575
6576 31 static ListData midi_list(midilist, &font);
6577
6578 static DIALOG midi_dlg[] =
6579 {
6580 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
6581 { jwin_win_proc, 8, 28, 304, 184, 0, 0, 0, D_EXIT, 0, 0, (void *) "MIDI Info", NULL, NULL },
6582 { jwin_text_proc, 32, 60, 40, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Tune:", NULL, NULL },
6583 { d_midilist_proc, 80, 56, 192, 16, 0, 0, 0, 0, 0, 0, (void *) &midi_list, NULL, NULL },
6584 { jwin_textbox_proc, 15, 80, 290, 96, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6585 { d_listen_proc, 24, 183, 72, 21, 0, 0, 'l', D_EXIT, -2, 0, (void *) "&Listen", NULL, NULL },
6586 { d_savemidi_proc, 108, 183, 72, 21, 0, 0, 's', D_EXIT, -3, 0, (void *) "&Save", NULL, NULL },
6587 { jwin_button_proc, 236, 183, 61, 21, 0, 0, 'k', D_EXIT, 0, 0, (void *) "O&K", NULL, NULL },
6588 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6589 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6590 };
6591
6592 void get_info(int32_t index)
6593 {
6594 int32_t i=0, m=0;
6595
6596 while(m<=index && i<=MAXMIDIS)
6597 {
6598 if(tunes[i].data)
6599 ++m;
6600
6601 ++i;
6602 }
6603
6604 --i;
6605
6606 if(i==MAXMIDIS && m<index)
6607 strcpy(text,"(null)");
6608 else
6609 {
6610 get_midi_info((MIDI*)tunes[i].data,zmi);
6611 get_midi_text((MIDI*)tunes[i].data,zmi,text);
6612 }
6613
6614 midi_dlg[0].dp2=get_zc_font(font_lfont);
6615 midi_dlg[3].dp = text;
6616 midi_dlg[3].d1 = midi_dlg[3].d2 = 0;
6617 midi_dlg[5].flags = (tunes[i].flags&tfDISABLESAVE) ? D_DISABLED : D_EXIT;
6618
6619 if(dialog_running)
6620 {
6621 jwin_textbox_proc(MSG_DRAW,midi_dlg+3,0);
6622 d_savemidi_proc(MSG_DRAW,midi_dlg+5,0);
6623 }
6624 }
6625
6626 int32_t onMIDICredits()
6627 {
6628 text = (char*)malloc(4096);
6629 zmi = (midi_info*)malloc(sizeof(midi_info));
6630
6631 if(!text || !zmi)
6632 {
6633 jwin_alert(NULL,"Not enough memory",NULL,NULL,"OK",NULL,13,27,get_zc_font(font_lfont));
6634 return D_O_K;
6635 }
6636
6637 bool do_pause_midi = midi_pos >= 0 && currmidi;
6638 auto restore_midi = currmidi;
6639 if(do_pause_midi)
6640 {
6641 paused_midi_pos = midi_pos;
6642 stop_midi();
6643 midi_paused=true;
6644 midi_suspended = midissuspHALTED;
6645 }
6646
6647 midi_dlg[0].dp2=get_zc_font(font_lfont);
6648 midi_dlg[2].d1 = 0;
6649 midi_dlg[2].d2 = 0;
6650 midi_dlg[4].flags = D_EXIT;
6651 midi_dlg[5].flags = (tunes[midi_dlg[2].d1].flags&tfDISABLESAVE) ? D_DISABLED : D_EXIT;
6652
6653 listening = false;
6654 dialog_running=false;
6655 get_info(0);
6656
6657 dialog_running=true;
6658
6659 large_dialog(midi_dlg);
6660
6661 zc_popup_dialog(midi_dlg,0);
6662 dialog_running=false;
6663
6664 if(listening)
6665 music_stop();
6666
6667 if(do_pause_midi)
6668 {
6669 midi_suspended = midissuspRESUME;
6670 currmidi = restore_midi;
6671 midi_pos = paused_midi_pos;
6672 }
6673
6674 if(text) free(text);
6675 if(zmi) free(zmi);
6676 return D_O_K;
6677 }
6678
6679 int32_t onAbout()
6680 {
6681 char buf1[80]={0};
6682 std::ostringstream oss;
6683 sprintf(buf1,"%s (%s), Version: %s", ZC_PLAYER_NAME,PROJECT_NAME,ZC_PLAYER_V);
6684 oss << buf1 << '\n';
6685 sprintf(buf1, "%s, Build %d", ALPHA_VER_STR, VERSION_BUILD);
6686 oss << buf1 << '\n';
6687 sprintf(buf1,"Build Date: %s %s, %d at @ %s %s", dayextension(BUILDTM_DAY).c_str(), (char*)months[BUILDTM_MONTH], BUILDTM_YEAR, __TIME__, __TIMEZONE__);
6688 oss << buf1 << '\n';
6689 sprintf(buf1, "Built By: %s", DEV_SIGNOFF);
6690 oss << buf1 << '\n';
6691 sprintf(buf1, "Tag: %s", getReleaseTag());
6692 oss << buf1 << '\n';
6693
6694 InfoDialog("About ZC", oss.str()).show();
6695 return D_O_K;
6696 }
6697
6698 int32_t onQuest()
6699 {
6700 char fname[100];
6701 strcpy(fname, get_filename(qstpath));
6702 quest_dlg[0].dp2=get_zc_font(font_lfont);
6703 quest_dlg[1].dp = fname;
6704
6705 if(QHeader.quest_number==0)
6706 sprintf(str_a,"Custom");
6707 else
6708 sprintf(str_a,"%d",QHeader.quest_number);
6709
6710 sprintf(str_s,"%s",VerStr(QHeader.zelda_version));
6711
6712 quest_dlg[11].d1 = quest_dlg[9].d1 = 0;
6713 quest_dlg[11].d2 = quest_dlg[9].d2 = 0;
6714
6715 large_dialog(quest_dlg);
6716
6717 zc_popup_dialog(quest_dlg, 0);
6718 return D_O_K;
6719 }
6720
6721 void call_vidmode_dlg();
6722 int32_t onVidMode()
6723 {
6724 call_vidmode_dlg();
6725 return D_O_K;
6726 }
6727
6728 #define addToHash(c,b,h) if(h->find(c ## key) == h->end()) \
6729 {(*h)[c ## key]=true;} else { if ( c ## key != 0 ) b = false;}
6730 //Added an extra statement, so that if the key is cleared to 0, the cleared
6731 //keybinding status need not be unique. -Z ( 1st April, 2019 )
6732
6733 void load_ukeys(int32_t* arr)
6734 {
6735 arr[ukey_a] = Akey;
6736 arr[ukey_b] = Bkey;
6737 arr[ukey_s] = Skey;
6738 arr[ukey_l] = Lkey;
6739 arr[ukey_r] = Rkey;
6740 arr[ukey_p] = Pkey;
6741 arr[ukey_ex1] = Exkey1;
6742 arr[ukey_ex2] = Exkey2;
6743 arr[ukey_ex3] = Exkey3;
6744 arr[ukey_ex4] = Exkey4;
6745 arr[ukey_du] = DUkey;
6746 arr[ukey_dd] = DDkey;
6747 arr[ukey_dl] = DLkey;
6748 arr[ukey_dr] = DRkey;
6749 arr[ukey_mod1a] = cheat_modifier_keys[0];
6750 arr[ukey_mod1b] = cheat_modifier_keys[1];
6751 arr[ukey_mod2a] = cheat_modifier_keys[2];
6752 arr[ukey_mod2b] = cheat_modifier_keys[3];
6753 };
6754
6755 static const char* ukey_names[] = {
6756 "A", "B", "Start", "L", "R", "Map",
6757 "Ex1", "Ex2", "Ex3", "Ex4", "Up", "Down",
6758 "Left", "Right", "Cheat Mod L1", "Cheat Mod L2",
6759 "Cheat Mod R1", "Cheat Mod R2",
6760 };
6761 std::string get_ukey_name(int32_t k)
6762 {
6763 if (k < num_ukey) return ukey_names[k];
6764 return "";
6765 }
6766
6767 int32_t onKeyboard()
6768 {
6769 int32_t a = Akey;
6770 int32_t b = Bkey;
6771 int32_t s = Skey;
6772 int32_t l = Lkey;
6773 int32_t r = Rkey;
6774 int32_t p = Pkey;
6775 int32_t ex1 = Exkey1;
6776 int32_t ex2 = Exkey2;
6777 int32_t ex3 = Exkey3;
6778 int32_t ex4 = Exkey4;
6779 int32_t du = DUkey;
6780 int32_t dd = DDkey;
6781 int32_t dl = DLkey;
6782 int32_t dr = DRkey;
6783 int32_t mod1a = cheat_modifier_keys[0];
6784 int32_t mod1b = cheat_modifier_keys[1];
6785 int32_t mod2a = cheat_modifier_keys[2];
6786 int32_t mod2b = cheat_modifier_keys[3];
6787 bool done=false;
6788 int32_t ret;
6789
6790 keyboard_control_dlg[0].dp2=get_zc_font(font_lfont);
6791
6792 large_dialog(keyboard_control_dlg);
6793
6794 while(!done)
6795 {
6796 ret = zc_popup_dialog(keyboard_control_dlg,3);
6797
6798 if(ret==3) // OK
6799 {
6800 int32_t ukeys[num_ukey];
6801 load_ukeys(ukeys);
6802 std::vector<std::string> uniqueError;
6803 for(int32_t q = 0; q < num_ukey; ++q)
6804 {
6805 for(int32_t p = q+1; p < num_ukey; ++p)
6806 {
6807 if(ukeys[q] == ukeys[p] && ukeys[q] != 0)
6808 {
6809 char buf[64];
6810 sprintf(buf, "'%s' conflicts with '%s'", get_ukey_name(q).c_str(), get_ukey_name(p).c_str());
6811 std::string str(buf);
6812 uniqueError.push_back(str);
6813 }
6814 }
6815 }
6816 if(uniqueError.size() == 0)
6817 {
6818 done = true;
6819 save_control_configs(true);
6820 }
6821 else
6822 {
6823 box_start(1, "Duplicate Keys", get_zc_font(font_lfont), get_zc_font(font_sfont), false, keyboard_control_dlg[0].w,keyboard_control_dlg[0].h, 2);
6824 box_out("Cannot have duplicate keybinds!"); box_eol();
6825 for(std::vector<std::string>::iterator it = uniqueError.begin();
6826 it != uniqueError.end(); ++it)
6827 {
6828 box_out((*it).c_str()); box_eol();
6829 }
6830 box_end(true);
6831 }
6832 }
6833 else // Cancel
6834 {
6835 Akey = a;
6836 Bkey = b;
6837 Skey = s;
6838 Lkey = l;
6839 Rkey = r;
6840 Pkey = p;
6841 Exkey1 = ex1;
6842 Exkey2 = ex2;
6843 Exkey3 = ex3;
6844 Exkey4 = ex4;
6845 DUkey = du;
6846 DDkey = dd;
6847 DLkey = dl;
6848 DRkey = dr;
6849 cheat_modifier_keys[0] = mod1a;
6850 cheat_modifier_keys[1] = mod1b;
6851 cheat_modifier_keys[2] = mod2a;
6852 cheat_modifier_keys[3] = mod2b;
6853
6854 done=true;
6855 }
6856
6857 rest(1);
6858 }
6859
6860 return D_O_K;
6861 }
6862
6863 int32_t onGamepad()
6864 {
6865 int32_t a = Abtn;
6866 int32_t b = Bbtn;
6867 int32_t s = Sbtn;
6868 int32_t l = Lbtn;
6869 int32_t r = Rbtn;
6870 int32_t m = Mbtn;
6871 int32_t p = Pbtn;
6872 int32_t ex1 = Exbtn1;
6873 int32_t ex2 = Exbtn2;
6874 int32_t ex3 = Exbtn3;
6875 int32_t ex4 = Exbtn4;
6876 int32_t up = DUbtn;
6877 int32_t down = DDbtn;
6878 int32_t left = DLbtn;
6879 int32_t right = DRbtn;
6880
6881 gamepad_dlg[0].dp2=get_zc_font(font_lfont);
6882 if(analog_movement)
6883 gamepad_dlg[56].flags|=D_SELECTED;
6884 else
6885 gamepad_dlg[56].flags&=~D_SELECTED;
6886
6887 large_dialog(gamepad_dlg);
6888
6889 int32_t ret = zc_popup_dialog(gamepad_dlg,4);
6890
6891 if(ret == 4) //OK
6892 {
6893 analog_movement = gamepad_dlg[56].flags&D_SELECTED;
6894 save_control_configs(false);
6895 }
6896 else //Cancel
6897 {
6898 Abtn = a;
6899 Bbtn = b;
6900 Sbtn = s;
6901 Lbtn = l;
6902 Rbtn = r;
6903 Mbtn = m;
6904 Pbtn = p;
6905 Exbtn1 = ex1;
6906 Exbtn2 = ex2;
6907 Exbtn3 = ex3;
6908 Exbtn4 = ex4;
6909 DUbtn = up;
6910 DDbtn = down;
6911 DLbtn = left;
6912 DRbtn = right;
6913 }
6914
6915 return D_O_K;
6916 }
6917
6918 int32_t onCheatKeys()
6919 {
6920 int32_t oldcheats[Cheat::Last][2];
6921 memcpy(oldcheats, cheatkeys, sizeof(cheatkeys));
6922
6923 bool done=false;
6924
6925 while(!done)
6926 {
6927 bool confirm = false;
6928 CheatKeysDialog(&confirm).show();
6929 if(confirm) // OK
6930 {
6931 std::vector<std::string> uniqueError;
6932 char buf[512];
6933 for(size_t q = 1; q < Cheat::Last; ++q)
6934 {
6935 if(cheatkeys[q][1] && !cheatkeys[q][0])
6936 {
6937 cheatkeys[q][0] = cheatkeys[q][1];
6938 cheatkeys[q][1] = 0;
6939 }
6940 }
6941 for(size_t q = 1; q < Cheat::Last; ++q)
6942 {
6943 if(!bindable_cheat((Cheat)q)) continue;
6944 for(size_t p = q+1; p < Cheat::Last; ++p)
6945 {
6946 if(!bindable_cheat((Cheat)p)) continue;
6947 for(size_t q2 = 0; q2 <= 1; ++q2)
6948 for(size_t p2 = 0; p2 <= 1; ++p2)
6949 {
6950 if(cheatkeys[q][q2] == cheatkeys[p][p2] && cheatkeys[q][q2] != 0)
6951 {
6952 uniqueError.push_back(fmt::format("'{}' ({}) conflicts with '{}' ({}) - both '{}'",
6953 cheat_to_string((Cheat)q), q2?"Alt":"Main",
6954 cheat_to_string((Cheat)p), p2?"Alt":"Main",
6955 get_keystr(cheatkeys[q][q2])));
6956 }
6957 }
6958 }
6959 }
6960 if(uniqueError.size() == 0)
6961 {
6962 done = true;
6963 save_cheatkeys();
6964 }
6965 else
6966 {
6967 box_start(1, "Duplicate Keys", get_zc_font(font_lfont), get_zc_font(font_sfont), false, 500,400, 2);
6968 box_out("Cannot have duplicate keybinds!"); box_eol();
6969 for(std::vector<std::string>::iterator it = uniqueError.begin();
6970 it != uniqueError.end(); ++it)
6971 {
6972 box_out((*it).c_str()); box_eol();
6973 }
6974 box_end(true);
6975 }
6976 }
6977 else // Cancel
6978 {
6979 memcpy(cheatkeys, oldcheats, sizeof(cheatkeys));
6980 done=true;
6981 }
6982 rest(1);
6983 }
6984
6985 return D_O_K;
6986 }
6987
6988 int32_t onSound()
6989 {
6990 if ( FFCore.coreflags&FFCORE_SCRIPTED_MIDI_VOLUME )
6991 {
6992 master_volume(-1,((int32_t)FFCore.usr_midi_volume));
6993 }
6994 if ( FFCore.coreflags&FFCORE_SCRIPTED_DIGI_VOLUME )
6995 {
6996 master_volume((int32_t)(FFCore.usr_digi_volume),1);
6997 }
6998 if ( FFCore.coreflags&FFCORE_SCRIPTED_MUSIC_VOLUME )
6999 {
7000 emusic_volume = (int32_t)FFCore.usr_music_volume;
7001 }
7002 if ( FFCore.coreflags&FFCORE_SCRIPTED_SFX_VOLUME )
7003 {
7004 sfx_volume = (int32_t)FFCore.usr_sfx_volume;
7005 }
7006 if ( FFCore.coreflags&FFCORE_SCRIPTED_PANSTYLE )
7007 {
7008 pan_style = (int32_t)FFCore.usr_panstyle;
7009 }
7010
7011 int32_t m = midi_volume;
7012 int32_t d = digi_volume;
7013 int32_t e = emusic_volume;
7014 int32_t b = zcmusic_bufsz;
7015 int32_t s = sfx_volume;
7016 int32_t p = pan_style;
7017 pan_style = vbound(pan_style,0,3);
7018
7019 sound_dlg[0].dp2=get_zc_font(font_lfont);
7020
7021 large_dialog(sound_dlg);
7022
7023 midi_dp[1] = sound_dlg[6].x;
7024 midi_dp[2] = sound_dlg[6].y;
7025 digi_dp[1] = sound_dlg[7].x;
7026 digi_dp[2] = sound_dlg[7].y;
7027 emus_dp[1] = sound_dlg[8].x;
7028 emus_dp[2] = sound_dlg[8].y;
7029 buf_dp[1] = sound_dlg[9].x;
7030 buf_dp[2] = sound_dlg[9].y;
7031 sfx_dp[1] = sound_dlg[10].x;
7032 sfx_dp[2] = sound_dlg[10].y;
7033 pan_dp[1] = sound_dlg[11].x;
7034 pan_dp[2] = sound_dlg[11].y;
7035 sound_dlg[15].d2 = (midi_volume==255) ? 32 : midi_volume>>3;
7036 sound_dlg[16].d2 = (digi_volume==255) ? 32 : digi_volume>>3;
7037 sound_dlg[17].d2 = (emusic_volume==255) ? 32 : emusic_volume>>3;
7038 sound_dlg[18].d2 = zcmusic_bufsz;
7039 sound_dlg[19].d2 = (sfx_volume==255) ? 32 : sfx_volume>>3;
7040 sound_dlg[20].d2 = pan_style;
7041
7042 int32_t ret = zc_popup_dialog(sound_dlg,1);
7043
7044 if(ret==2)
7045 {
7046 master_volume(digi_volume,midi_volume);
7047
7048 for(int32_t i=0; i<WAV_COUNT; ++i)
7049 {
7050 //allegro assertion fails when passing in -1 as voice -DD
7051 if(sfx_voice[i] > 0)
7052 voice_set_volume(sfx_voice[i], sfx_volume);
7053 }
7054 zc_set_config(sfx_sect,"digi",digi_volume);
7055 zc_set_config(sfx_sect,"midi",midi_volume);
7056 zc_set_config(sfx_sect,"sfx",sfx_volume);
7057 zc_set_config(sfx_sect,"emusic",emusic_volume);
7058 zc_set_config(sfx_sect,"pan",pan_style);
7059 zc_set_config(sfx_sect,"zcmusic_bufsz",zcmusic_bufsz);
7060 }
7061 else
7062 {
7063 midi_volume = m;
7064 digi_volume = d;
7065 emusic_volume = e;
7066 zcmusic_bufsz = b;
7067 sfx_volume = s;
7068 pan_style = p;
7069 }
7070
7071 return D_O_K;
7072 }
7073
7074 int32_t queding(char const* s1, char const* s2, char const* s3)
7075 {
7076 return jwin_alert(ZC_str,s1,s2,s3,"&Yes","&No",'y','n',get_zc_font(font_lfont));
7077 }
7078
7079 int32_t onQuit()
7080 {
7081 if(Playing)
7082 {
7083 int32_t ret=0;
7084
7085 if(get_bit(quest_rules, qr_NOCONTINUE))
7086 {
7087 if(standalone_mode)
7088 {
7089 ret=queding("End current game?",
7090 "The continue screen is disabled; the game",
7091 "will be reloaded from the last save.");
7092 }
7093 else
7094 {
7095 ret=queding("End current game?",
7096 "The continue screen is disabled. You will",
7097 "be returned to the file select screen.");
7098 }
7099 }
7100 else
7101 ret=queding("End current game?",NULL,NULL);
7102
7103 if(ret==1)
7104 {
7105 disableClickToFreeze=false;
7106 Quit=qQUIT;
7107
7108 // Trying to evade a door repair charge?
7109 if(repaircharge)
7110 {
7111 game->change_drupy(-repaircharge);
7112 repaircharge=0;
7113 }
7114
7115 return D_CLOSE;
7116 }
7117 }
7118
7119 return D_O_K;
7120 }
7121
7122 int32_t onTryQuitMenu()
7123 {
7124 return onTryQuit(true);
7125 }
7126
7127 int32_t onTryQuit(bool inMenu)
7128 {
7129 if(Playing && !(GameFlags & GAMEFLAG_NO_F6))
7130 {
7131 if(active_cutscene.can_f6())
7132 {
7133 if(get_bit(quest_rules,qr_OLD_F6))
7134 {
7135 if(inMenu) onQuit();
7136 else /*if(!get_bit(quest_rules, qr_NOCONTINUE))*/ f_Quit(qQUIT);
7137 }
7138 else
7139 {
7140 disableClickToFreeze=false;
7141 GameFlags |= GAMEFLAG_TRYQUIT;
7142 }
7143 return D_CLOSE;
7144 }
7145 else active_cutscene.error();
7146 }
7147
7148 return D_O_K;
7149 }
7150
7151 int32_t onReset()
7152 {
7153 if(queding(" Reset system? ",NULL,NULL)==1)
7154 {
7155 disableClickToFreeze=false;
7156 Quit=qRESET;
7157 replay_quit();
7158 return D_CLOSE;
7159 }
7160
7161 return D_O_K;
7162 }
7163
7164 int32_t onExit()
7165 {
7166 if(queding(" Quit Zelda Classic? ",NULL,NULL)==1)
7167 {
7168 Quit=qEXIT;
7169 return D_CLOSE;
7170 }
7171
7172 return D_O_K;
7173 }
7174
7175 int32_t onTitle_NES()
7176 {
7177 title_version=0;
7178 zc_set_config(cfg_sect,"title",title_version);
7179 return D_O_K;
7180 }
7181 int32_t onTitle_DX()
7182 {
7183 title_version=1;
7184 zc_set_config(cfg_sect,"title",title_version);
7185 return D_O_K;
7186 }
7187 int32_t onTitle_25()
7188 {
7189 title_version=2;
7190 zc_set_config(cfg_sect,"title",title_version);
7191 return D_O_K;
7192 }
7193
7194 int32_t onDebug()
7195 {
7196 if(debug_enabled)
7197 set_debug(!get_debug());
7198 return D_O_K;
7199 }
7200
7201 int32_t onHeartBeep()
7202 {
7203 heart_beep=!heart_beep;
7204 zc_set_config(cfg_sect,"heart_beep",heart_beep);
7205 return D_O_K;
7206 }
7207
7208 int32_t onSaveIndicator()
7209 {
7210 use_save_indicator=!use_save_indicator;
7211 zc_set_config(cfg_sect,"save_indicator",use_save_indicator);
7212 return D_O_K;
7213 }
7214
7215 int32_t onEpilepsy()
7216 {
7217 if(jwin_alert3(
7218 "Epilepsy Flash Reduction",
7219 "Enabling this will reduce the intensity of flashing and screen wave effects.",
7220 "Disabling this will restore standard flash and wavy behaviour.",
7221 "Proceed?",
7222 "&Yes",
7223 "&No",
7224 NULL,
7225 'y',
7226 'n',
7227 0,
7228 get_zc_font(font_lfont)) == 1)
7229 {
7230 epilepsyFlashReduction = epilepsyFlashReduction ? 0 : 1;
7231 zc_set_config("zeldadx","checked_epilepsy",1);
7232 zc_set_config(cfg_sect,"epilepsy_flash_reduction",epilepsyFlashReduction);
7233 }
7234 return D_O_K;
7235 }
7236
7237 int32_t onTriforce()
7238 {
7239 for(int32_t i=0; i<MAXINITTABS; ++i)
7240 {
7241 init_tabs[i].flags&=~D_SELECTED;
7242 }
7243
7244 init_tabs[3].flags=D_SELECTED;
7245 return onCheatConsole();
7246 /*triforce_dlg[0].dp2=get_zc_font(font_lfont);
7247 for(int32_t i=1; i<=8; i++)
7248 triforce_dlg[i].flags = (game->lvlitems[i] & liTRIFORCE) ? D_SELECTED : 0;
7249
7250 if(zc_popup_dialog (triforce_dlg,-1)==9)
7251 {
7252 for(int32_t i=1; i<=8; i++)
7253 {
7254 game->lvlitems[i] &= ~liTRIFORCE;
7255 game->lvlitems[i] |= (triforce_dlg[i].flags & D_SELECTED) ? liTRIFORCE : 0;
7256 }
7257 }
7258 return D_O_K;*/
7259 }
7260
7261 bool rc = false;
7262 /*
7263 int32_t onEquipment()
7264 {
7265 for (int32_t i=0; i<MAXINITTABS; ++i)
7266 {
7267 init_tabs[i].flags&=~D_SELECTED;
7268 }
7269 init_tabs[0].flags=D_SELECTED;
7270 return onCheatConsole();
7271 }
7272 */
7273
7274 int32_t onItems()
7275 {
7276 for(int32_t i=0; i<MAXINITTABS; ++i)
7277 {
7278 init_tabs[i].flags&=~D_SELECTED;
7279 }
7280
7281 init_tabs[1].flags=D_SELECTED;
7282 return onCheatConsole();
7283 }
7284
7285 static DIALOG getnum_dlg[] =
7286 {
7287 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp)
7288 { jwin_win_proc, 80, 80, 160, 72, vc(0), vc(11), 0, D_EXIT, 0, 0, NULL, NULL, NULL },
7289 { jwin_text_proc, 104, 104+4, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Number:", NULL, NULL },
7290 { jwin_edit_proc, 168, 104, 48, 16, 0, 0, 0, 0, 6, 0, NULL, NULL, NULL },
7291 { jwin_button_proc, 90, 126, 61, 21, vc(0), vc(11), 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
7292 { jwin_button_proc, 170, 126, 61, 21, vc(0), vc(11), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
7293 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
7294 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
7295 };
7296
7297 int32_t getnumber(const char *prompt,int32_t initialval)
7298 {
7299 char buf[20];
7300 sprintf(buf,"%d",initialval);
7301 getnum_dlg[0].dp=(void *)prompt;
7302 getnum_dlg[0].dp2=get_zc_font(font_lfont);
7303 getnum_dlg[2].dp=buf;
7304
7305 large_dialog(getnum_dlg);
7306
7307 if(zc_popup_dialog(getnum_dlg,2)==3)
7308 return atoi(buf);
7309
7310 return initialval;
7311 }
7312
7313 int32_t onLife()
7314 {
7315 int value = vbound(getnumber("Life",game->get_life()),1,game->get_maxlife());
7316 cheats_enqueue(Cheat::Life, value);
7317 return D_O_K;
7318 }
7319
7320 int32_t onHeartC()
7321 {
7322 int max_life = vbound(getnumber("Heart Containers",game->get_maxlife()/game->get_hp_per_heart()),1,4095) * game->get_hp_per_heart();
7323 int life = vbound(getnumber("Life",game->get_life()/game->get_hp_per_heart()),1,max_life/game->get_hp_per_heart())*game->get_hp_per_heart();
7324 cheats_enqueue(Cheat::MaxLife, max_life);
7325 cheats_enqueue(Cheat::Life, life);
7326 return D_O_K;
7327 }
7328
7329 int32_t onMagicC()
7330 {
7331 int max_magic = vbound(getnumber("Magic Containers",game->get_maxmagic()/game->get_mp_per_block()),0,2047) * game->get_mp_per_block();
7332 int magic = vbound(getnumber("Magic",game->get_magic()/game->get_mp_per_block()),0,game->get_maxmagic()/game->get_mp_per_block())*game->get_mp_per_block();
7333 cheats_enqueue(Cheat::MaxMagic, max_magic);
7334 cheats_enqueue(Cheat::Magic, magic);
7335 return D_O_K;
7336 }
7337
7338 int32_t onRupies()
7339 {
7340 int value = vbound(getnumber("Rupees",game->get_rupies()),0,game->get_maxcounter(1));
7341 cheats_enqueue(Cheat::Rupies, value);
7342 return D_O_K;
7343 }
7344
7345 int32_t onMaxBombs()
7346 {
7347 int value = vbound(getnumber("Max Bombs",game->get_maxbombs()),0,0xFFFF);
7348 cheats_enqueue(Cheat::MaxBombs, value);
7349 cheats_enqueue(Cheat::Bombs, value);
7350 return D_O_K;
7351 }
7352
7353 int32_t onRefillLife()
7354 {
7355 cheats_enqueue(Cheat::Life, game->get_maxlife());
7356 return D_O_K;
7357 }
7358 int32_t onRefillMagic()
7359 {
7360 cheats_enqueue(Cheat::Magic, game->get_maxmagic());
7361 return D_O_K;
7362 }
7363 int32_t onClock()
7364 {
7365 cheats_enqueue(Cheat::Clock);
7366 return D_O_K;
7367 }
7368
7369 int32_t onQstPath()
7370 {
7371 char path[2048];
7372
7373 chop_path(qstdir);
7374 strcpy(path,qstdir);
7375
7376 go();
7377
7378 if(jwin_dfile_select_ex("Quest File Directory", path, "qst", 2048, -1, -1, get_zc_font(font_lfont)))
7379 {
7380 chop_path(path);
7381 fix_filename_case(path);
7382 fix_filename_slashes(path);
7383 strcpy(qstdir,path);
7384 strcpy(qstpath,qstdir);
7385 }
7386
7387 comeback();
7388 return D_O_K;
7389 }
7390
7391 #include "dialog/cheat_dialog.h"
7392 int32_t onCheat()
7393 {
7394 call_setcheat_dialog();
7395 game->set_cheat(maxcheat);
7396 if(cheat) game->did_cheat(true);
7397 return D_O_K;
7398 }
7399
7400 int32_t onCheatRupies()
7401 {
7402 cheats_enqueue(Cheat::Rupies, game->get_maxcounter(1));
7403 return D_O_K;
7404 }
7405
7406 int32_t onCheatArrows()
7407 {
7408 cheats_enqueue(Cheat::Arrows, game->get_maxarrows());
7409 return D_O_K;
7410 }
7411
7412 int32_t onCheatBombs()
7413 {
7414 cheats_enqueue(Cheat::Bombs, game->get_maxbombs(), game->get_maxcounter(6));
7415 return D_O_K;
7416 }
7417
7418 // *** screen saver
7419
7420 7521864 int32_t after_time()
7421 {
7422
1/2
✓ Branch 0 taken 7521864 times.
✗ Branch 1 not taken.
7521864 if(ss_enable == 0)
7423 return INT_MAX;
7424
7425
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7521864 times.
7521864 if(ss_after <= 0)
7426 return 5 * 60;
7427
7428
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7521864 times.
7521864 if(ss_after <= 3)
7429 return ss_after * 15 * 60;
7430
7431
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7521864 times.
7521864 if(ss_after <= 13)
7432 return (ss_after - 3) * 60 * 60;
7433
7434 7521864 return MAX_IDLE + 1;
7435 7521864 }
7436
7437 static const char *after_str[15] =
7438 {
7439 " 5 sec", "15 sec", "30 sec", "45 sec", " 1 min", " 2 min", " 3 min",
7440 " 4 min", " 5 min", " 6 min", " 7 min", " 8 min", " 9 min", "10 min",
7441 "Never"
7442 };
7443
7444 const char *after_list(int32_t index, int32_t *list_size)
7445 {
7446 if(index < 0)
7447 {
7448 *list_size = 15;
7449 return NULL;
7450 }
7451
7452 return after_str[index];
7453 }
7454
7455 31 static ListData after__list(after_list, &font);
7456
7457 static DIALOG scrsaver_dlg[] =
7458 {
7459 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
7460 31 { jwin_win_proc, 32, 64, 256, 136, 0, 0, 0, D_EXIT, 0, 0, (void *) "Screen Saver Settings", NULL, NULL },
7461 31 { jwin_frame_proc, 42, 92, 236, 70, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
7462 31 { jwin_text_proc, 60, 104, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Run After", NULL, NULL },
7463 31 { jwin_text_proc, 60, 128, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Speed", NULL, NULL },
7464 31 { jwin_text_proc, 60, 144, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Density", NULL, NULL },
7465 31 { jwin_droplist_proc, 144, 100, 96, 16, 0, 0, 0, 0, 0, 0, (void *) &after__list, NULL, NULL },
7466 31 { jwin_slider_proc, 144, 128, 116, 8, vc(0), jwin_pal[jcBOX], 0, 0, 6, 0, NULL, NULL, NULL },
7467 31 { jwin_slider_proc, 144, 144, 116, 8, vc(0), jwin_pal[jcBOX], 0, 0, 6, 0, NULL, NULL, NULL },
7468 31 { jwin_button_proc, 42, 170, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
7469 31 { jwin_button_proc, 124, 170, 72, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Preview", NULL, NULL },
7470 31 { jwin_button_proc, 218, 170, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
7471 31 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
7472 31 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
7473 };
7474
7475 int32_t onScreenSaver()
7476 {
7477 scrsaver_dlg[0].dp2=get_zc_font(font_lfont);
7478 int32_t oldcfgs[3];
7479 scrsaver_dlg[5].d1 = scrsaver_dlg[5].d2 = oldcfgs[0] = ss_after;
7480 scrsaver_dlg[6].d2 = oldcfgs[1] = ss_speed;
7481 scrsaver_dlg[7].d2 = oldcfgs[2] = ss_density;
7482
7483 large_dialog(scrsaver_dlg);
7484
7485 int32_t ret = zc_popup_dialog(scrsaver_dlg,-1);
7486
7487 if(ret == 8 || ret == 9)
7488 {
7489 ss_after = scrsaver_dlg[5].d1;
7490 ss_speed = scrsaver_dlg[6].d2;
7491 ss_density = scrsaver_dlg[7].d2;
7492 if(oldcfgs[0] != ss_after)
7493 zc_set_config(cfg_sect,"ss_after",ss_after);
7494 if(oldcfgs[1] != ss_speed)
7495 zc_set_config(cfg_sect,"ss_speed",ss_speed);
7496 if(oldcfgs[2] != ss_density)
7497 zc_set_config(cfg_sect,"ss_density",ss_density);
7498 }
7499
7500 if(ret == 9)
7501 // preview Screen Saver
7502 {
7503 clear_keybuf();
7504 Matrix(ss_speed, ss_density, 30);
7505 system_pal();
7506 }
7507
7508 return D_O_K;
7509 }
7510
7511 /***** Menus *****/
7512
7513 static MENU game_menu[] =
7514 {
7515 { (char *)"&Continue\tESC", onContinue, NULL, 0, NULL },
7516 { (char *)"", NULL, NULL, 0, NULL },
7517 { (char *)"L&oad Quest...", onCustomGame, NULL, 0, NULL },
7518 { (char *)"&End Game\tF6", onTryQuitMenu, NULL, 0, NULL },
7519 { (char *)"", NULL, NULL, 0, NULL },
7520 #ifdef __EMSCRIPTEN__
7521 { (char *)"&Reset\tF7", onReset, NULL, 0, NULL },
7522 #elif defined(ALLEGRO_MACOSX)
7523 { (char *)"&Reset\tF7", onReset, NULL, 0, NULL },
7524 { (char *)"&Quit\tF8", onExit, NULL, 0, NULL },
7525 #else
7526 { (char *)"&Reset\tF9", onReset, NULL, 0, NULL },
7527 { (char *)"&Quit\tF10", onExit, NULL, 0, NULL },
7528 #endif
7529 { NULL, NULL, NULL, 0, NULL }
7530 };
7531
7532 static MENU title_menu[] =
7533 {
7534 { (char *)"&Original", onTitle_NES, NULL, 0, NULL },
7535 { (char *)"&Zelda Classic", onTitle_DX, NULL, 0, NULL },
7536 { (char *)"Zelda Classic &2.50", onTitle_25, NULL, 0, NULL },
7537 { NULL, NULL, NULL, 0, NULL }
7538 };
7539
7540 static MENU snapshot_format_menu[] =
7541 {
7542 { (char *)"&BMP", onSetSnapshotFormat, NULL, 0, NULL },
7543 { (char *)"&GIF", onSetSnapshotFormat, NULL, 0, NULL },
7544 { (char *)"&JPG", onSetSnapshotFormat, NULL, 0, NULL },
7545 { (char *)"&PNG", onSetSnapshotFormat, NULL, 0, NULL },
7546 { (char *)"PC&X", onSetSnapshotFormat, NULL, 0, NULL },
7547 { (char *)"&TGA", onSetSnapshotFormat, NULL, 0, NULL },
7548 { NULL, NULL, NULL, 0, NULL }
7549 };
7550
7551 static MENU controls_menu[] =
7552 {
7553 { (char *)"Key&board...", onKeyboard, NULL, 0, NULL },
7554 { (char *)"&Gamepad...", onGamepad, NULL, 0, NULL },
7555 { (char *)"&Cheat Keys...", onCheatKeys, NULL, 0, NULL },
7556 { NULL, NULL, NULL, 0, NULL }
7557 };
7558
7559 static MENU name_entry_mode_menu[] =
7560 {
7561 { (char *)"&Keyboard", onKeyboardEntry, NULL, 0, NULL },
7562 { (char *)"&Letter Grid", onLetterGridEntry, NULL, 0, NULL },
7563 { (char *)"&Extended Letter Grid", onExtLetterGridEntry, NULL, 0, NULL },
7564 { NULL, NULL, NULL, 0, NULL }
7565 };
7566
7567 static void set_controls_menu_active()
7568 {
7569
7570 }
7571
7572 static MENU window_menu[] =
7573 {
7574 { "Lock Aspect Ratio", onDragAspect, NULL, 0, NULL },
7575 { "Lock Integer Scale", onIntegerScaling, NULL, 0, NULL },
7576 { "Save Size Changes", onSaveDragResize, NULL, 0, NULL },
7577 { "Save Position Changes", onWinPosSave, NULL, 0, NULL },
7578 { "Stretch Game Area", onStretchGame, NULL, 0, NULL },
7579 { NULL, NULL, NULL, 0, NULL }
7580 };
7581 static MENU options_menu[] =
7582 {
7583 { "&Title Screen", NULL, title_menu, 0, NULL },
7584 { "Name &Entry Mode", NULL, name_entry_mode_menu, 0, NULL },
7585 { "S&napshot Format", NULL, snapshot_format_menu, 0, NULL },
7586 { "&Window Settings", NULL, window_menu, 0, NULL },
7587 { "Epilepsy Flash Reduction", onEpilepsy, NULL, 0, NULL },
7588 { "Windows MIDI Patch", onMIDIPatch, NULL, 0, NULL },
7589 { NULL, NULL, NULL, 0, NULL }
7590 };
7591 static MENU settings_menu[] =
7592 {
7593 { "&Sound...", onSound, NULL, 0, NULL },
7594 { "C&ontrols", NULL, controls_menu, 0, NULL },
7595 { "", NULL, NULL, 0, NULL },
7596 { "Options", NULL, options_menu, 0, NULL },
7597 { "", NULL, NULL, 0, NULL },
7598 //
7599 { "&Cap FPS\tF1", onVsync, NULL, 0, NULL },
7600 { "Show &FPS\tF2", onShowFPS, NULL, 0, NULL },
7601 { "Click to Freeze", onClickToFreeze, NULL, 0, NULL },
7602 { "Cont. &Heart Beep", onHeartBeep, NULL, 0, NULL },
7603 { "Show Trans. &Layers", onTransLayers, NULL, 0, NULL },
7604 //
7605 { "Up+A+B To &Quit", onNESquit, NULL, 0, NULL },
7606 { "Volume &Keys", onVolKeys, NULL, 0, NULL },
7607 { "Sa&ve Indicator", onSaveIndicator, NULL, 0, NULL },
7608 { "", NULL, NULL, 0, NULL },
7609 { "Debu&g", onDebug, NULL, 0, NULL },
7610 //
7611 { NULL, NULL, NULL, 0, NULL }
7612 };
7613
7614
7615 static MENU misc_menu[] =
7616 {
7617 { (char *)"&About...", onAbout, NULL, 0, NULL },
7618 { (char *)"&Credits...", onCredits, NULL, 0, NULL },
7619 { (char *)"&Fullscreen", onFullscreenMenu, NULL, 0, NULL },
7620 { (char *)"&Video Mode...", onVidMode, NULL, 0, NULL },
7621 { (char *)"", NULL, NULL, 0, NULL },
7622 //5
7623 { (char *)"&Quest Info...", onQuest, NULL, 0, NULL },
7624 { (char *)"Quest &MIDI Info...", onMIDICredits, NULL, 0, NULL },
7625 { (char *)"Quest &Directory...", onQstPath, NULL, 0, NULL },
7626 { (char *)"", NULL, NULL, 0, NULL },
7627 { (char *)"Take &Snapshot\tF12", onSnapshot, NULL, 0, NULL },
7628 //10
7629 { (char *)"Sc&reen Saver...", onScreenSaver, NULL, 0, NULL },
7630 { (char *)"Save ZC Configuration", OnSaveZCConfig, NULL, 0, NULL },
7631 { (char *)"Show ZASM Debugger", onConsoleZASM, NULL, 0, NULL },
7632 { (char *)"Show ZScript Debugger", onConsoleZScript, NULL, 0, NULL },
7633 { (char *)"Clear Console on Qst Load", onClrConsoleOnLoad, NULL, 0, NULL },
7634 //15
7635 { (char *)"Clear Directory Cache", OnnClearQuestDir, NULL, 0, NULL },
7636 { (char *)"Modules", NULL, zcmodule_menu, 0, NULL },
7637 { NULL, NULL, NULL, 0, NULL }
7638 };
7639
7640 static MENU refill_menu[] =
7641 {
7642 { (char *)"&Life", onRefillLife, NULL, 0, NULL },
7643 { (char *)"&Magic", onRefillMagic, NULL, 0, NULL },
7644 { (char *)"&Bombs", onCheatBombs, NULL, 0, NULL },
7645 { (char *)"&Rupees", onCheatRupies, NULL, 0, NULL },
7646 { (char *)"&Arrows", onCheatArrows, NULL, 0, NULL },
7647 { NULL, NULL, NULL, 0, NULL }
7648 };
7649
7650 static MENU show_menu[] =
7651 {
7652 { (char *)"Combos", onShowLayer0, NULL, 0, NULL },
7653 { (char *)"Layer 1", onShowLayer1, NULL, 0, NULL },
7654 { (char *)"Layer 2", onShowLayer2, NULL, 0, NULL },
7655 { (char *)"Layer 3", onShowLayer3, NULL, 0, NULL },
7656 { (char *)"Layer 4", onShowLayer4, NULL, 0, NULL },
7657 { (char *)"Layer 5", onShowLayer5, NULL, 0, NULL },
7658 { (char *)"Layer 6", onShowLayer6, NULL, 0, NULL },
7659 { (char *)"Overhead Combos", onShowLayerO, NULL, 0, NULL },
7660 { (char *)"Push Blocks", onShowLayerP, NULL, 0, NULL },
7661 { (char *)"Freeform Combos", onShowLayerF, NULL, 0, NULL },
7662 { (char *)"Sprites", onShowLayerS, NULL, 0, NULL },
7663 { (char *)"", NULL, NULL, 0, NULL },
7664 { (char *)"Current FFC Scripts", onShowFFScripts, NULL, 0, NULL },
7665 { (char *)"", NULL, NULL, 0, NULL },
7666 { (char *)"Walkability", onShowLayerW, NULL, 0, NULL },
7667 { (char *)"Hitboxes", onShowHitboxes, NULL, 0, NULL },
7668 { (char *)"Effects", onShowLayerE, NULL, 0, NULL },
7669 { (char *)"Info Opacity", onShowInfoOpacity, NULL, 0, NULL },
7670 { NULL, NULL, NULL, 0, NULL }
7671 };
7672
7673 static MENU cheat_menu[] =
7674 {
7675 { (char *)"Set &Cheat", onCheat, NULL, 0, NULL },
7676 { (char *)"", NULL, NULL, 0, NULL },
7677 { (char *)"Re&fill", NULL, refill_menu, 0, NULL },
7678 { (char *)"", NULL, NULL, 0, NULL },
7679 { (char *)"&Invincible", onClock, NULL, 0, NULL },
7680 { (char *)"Ma&x Bombs...", onMaxBombs, NULL, 0, NULL },
7681 { (char *)"&Heart Containers...", onHeartC, NULL, 0, NULL },
7682 { (char *)"&Magic Containers...", onMagicC, NULL, 0, NULL },
7683 { (char *)"", NULL, NULL, 0, NULL },
7684 { (char *)"&Player Data...", onCheatConsole, NULL, 0, NULL },
7685 { (char *)"", NULL, NULL, 0, NULL },
7686 { (char *)"Walk Through &Walls", onNoWalls, NULL, 0, NULL },
7687 { (char *)"Player Ignores Side&view", onIgnoreSideview, NULL, 0, NULL },
7688 { (char *)"&Quick Movement", onGoFast, NULL, 0, NULL },
7689 { (char *)"&Kill All Enemies", onKillCheat, NULL, 0, NULL },
7690 { (char *)"Trigger &Secrets", onSecretsCheat, NULL, 0, NULL },
7691 { (char *)"Trigger Secrets Perm", onSecretsCheatPerm, NULL, 0, NULL },
7692 { (char *)"Show/Hide Layer", NULL, show_menu, 0, NULL },
7693 { (char *)"Toggle &Light", onLightSwitch, NULL, 0, NULL },
7694 { (char *)"&Goto Location...", onGoTo, NULL, 0, NULL },
7695 { NULL, NULL, NULL, 0, NULL }
7696 };
7697
7698 #if DEVLEVEL > 0
7699 int32_t devLogging();
7700 int32_t devDebug();
7701 int32_t devTimestmp();
7702 #if DEVLEVEL > 1
7703 int32_t setCheat();
7704 #endif //DEVLEVEL > 1
7705 enum
7706 {
7707 dv_log,
7708 // dv_dbg,
7709 dv_tmpstmp,
7710 #if DEVLEVEL > 1
7711 dv_nil,
7712 dv_setcheat,
7713 #endif //DEVLEVEL > 1
7714 dv_max
7715 };
7716 static MENU dev_menu[] =
7717 {
7718 { (char *)"&Force Error Log", devLogging, NULL, 0, NULL },
7719 // { (char *)"&Extra Debug Log", devDebug, NULL, 0, NULL },
7720 { (char *)"&Timestamp Log", devTimestmp, NULL, 0, NULL },
7721 #if DEVLEVEL > 1
7722 { (char *)"", NULL, NULL, 0, NULL },
7723 { (char *)"Set &Cheat", setCheat, NULL, 0, NULL },
7724 #endif //DEVLEVEL > 1
7725 { NULL, NULL, NULL, 0, NULL }
7726 };
7727 int32_t devLogging()
7728 {
7729 dev_logging = !dev_logging;
7730 dev_menu[dv_log].flags = dev_logging ? D_SELECTED : 0;
7731 return D_O_K;
7732 }
7733 // int32_t devDebug()
7734 // {
7735 // dev_debug = !dev_debug;
7736 // dev_menu[dv_dbg].flags = dev_debug ? D_SELECTED : 0;
7737 // return D_O_K;
7738 // }
7739 int32_t devTimestmp()
7740 {
7741 dev_timestmp = !dev_timestmp;
7742 dev_menu[dv_tmpstmp].flags = dev_timestmp ? D_SELECTED : 0;
7743 return D_O_K;
7744 }
7745 #if DEVLEVEL > 1
7746 int32_t setCheat()
7747 {
7748 cheat = (vbound(getnumber("Cheat Level",cheat), 0, 4));
7749 return D_O_K;
7750 }
7751 #endif //DEVLEVEL > 1
7752 #endif //DEVLEVEL > 0
7753
7754 MENU the_player_menu[] =
7755 {
7756 { (char *)"&Game", NULL, game_menu, 0, NULL },
7757 { (char *)"&Settings", NULL, settings_menu, 0, NULL },
7758 { (char *)"&Cheat", NULL, cheat_menu, 0, NULL },
7759 { (char *)"Replay", NULL, replay_menu, 0, NULL },
7760 { (char *)"&ZC", NULL, misc_menu, 0, NULL },
7761 #if DEVLEVEL > 0
7762 { (char *)"&Dev", NULL, dev_menu, 0, NULL },
7763 #endif
7764 { NULL, NULL, NULL, 0, NULL }
7765 };
7766 int32_t onMIDIPatch()
7767 {
7768 if(jwin_alert3(
7769 "Toggle Windows MIDI Fix",
7770 "This action will change whether ZC Player auto-restarts a MIDI at its",
7771 "last index if you move ZC Player out of focus, then back into focus.",
7772 "Proceed?",
7773 "&Yes",
7774 "&No",
7775 NULL,
7776 'y',
7777 'n',
7778 0,
7779 get_zc_font(font_lfont)) == 1)
7780 {
7781 midi_patch_fix = midi_patch_fix ? 0 : 1;
7782 zc_set_config("zeldadx","midi_patch_fix",midi_patch_fix);
7783 }
7784 options_menu[5].flags =(midi_patch_fix)?D_SELECTED:0;
7785 return D_O_K;
7786 }
7787
7788 int32_t onKeyboardEntry()
7789 {
7790 NameEntryMode=0;
7791 zc_set_config(cfg_sect,"name_entry_mode",NameEntryMode);
7792 return D_O_K;
7793 }
7794
7795 int32_t onLetterGridEntry()
7796 {
7797 NameEntryMode=1;
7798 zc_set_config(cfg_sect,"name_entry_mode",NameEntryMode);
7799 return D_O_K;
7800 }
7801
7802 int32_t onExtLetterGridEntry()
7803 {
7804 NameEntryMode=2;
7805 zc_set_config(cfg_sect,"name_entry_mode",NameEntryMode);
7806 return D_O_K;
7807 }
7808
7809 static BITMAP* oldscreen;
7810 int32_t onFullscreenMenu()
7811 {
7812 // super hacks
7813 screen = oldscreen;
7814 if (onFullscreen() == D_REDRAW)
7815 {
7816 oldscreen = screen;
7817 }
7818 screen = menu_bmp;
7819 misc_menu[2].flags =(isFullScreen()==1)?D_SELECTED:0;
7820 return D_O_K;
7821 }
7822
7823 31 void fix_menu()
7824 {
7825
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 31 times.
31 if(!debug_enabled)
7826 31 settings_menu[13].text = NULL;
7827 31 }
7828
7829 static DIALOG system_dlg[] =
7830 {
7831 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) */
7832 { jwin_menu_proc, 0, 0, 0, 0, 0, 0, 0, D_USER, 0, 0, (void *) the_player_menu, NULL, NULL },
7833 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F1, 0, (void *) onVsync, NULL, NULL },
7834 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F2, 0, (void *) onShowFPS, NULL, NULL },
7835 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F6, 0, (void *) onTryQuitMenu, NULL, NULL },
7836 #ifndef ALLEGRO_MACOSX
7837 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F9, 0, (void *) onReset, NULL, NULL },
7838 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F10, 0, (void *) onExit, NULL, NULL },
7839 #else
7840 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F7, 0, (void *) onReset, NULL, NULL },
7841 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F8, 0, (void *) onExit, NULL, NULL },
7842 #endif
7843 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F12, 0, (void *) onSnapshot, NULL, NULL },
7844 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_TAB, 0, (void *) onDebug, NULL, NULL },
7845 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
7846 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
7847 };
7848
7849 void reset_snapshot_format_menu()
7850 {
7851 for(int32_t i=0; i<ssfmtMAX; ++i)
7852 {
7853 snapshot_format_menu[i].flags=0;
7854 }
7855 }
7856
7857 int32_t onSetSnapshotFormat()
7858 {
7859 switch(active_menu->text[1])
7860 {
7861 case 'B': //"&BMP"
7862 SnapshotFormat=0;
7863 break;
7864
7865 case 'G': //"&GIF"
7866 SnapshotFormat=1;
7867 break;
7868
7869 case 'J': //"&JPG"
7870 SnapshotFormat=2;
7871 break;
7872
7873 case 'P': //"&PNG"
7874 SnapshotFormat=3;
7875 break;
7876
7877 case 'C': //"PC&X"
7878 SnapshotFormat=4;
7879 break;
7880
7881 case 'T': //"&TGA"
7882 SnapshotFormat=5;
7883 break;
7884
7885 case 'L': //"&LBM"
7886 SnapshotFormat=6;
7887 break;
7888 }
7889 zc_set_config("zeldadx", "snapshot_format", SnapshotFormat);
7890
7891 snapshot_format_menu[SnapshotFormat].flags=D_SELECTED;
7892 return D_O_K;
7893 }
7894
7895
7896 45 void color_layer(RGB *src,RGB *dest,char r,char g,char b,char pos,int32_t from,int32_t to)
7897 {
7898 PALETTE tmp;
7899
7900
2/2
✓ Branch 0 taken 11520 times.
✓ Branch 1 taken 45 times.
11565 for(int32_t i=0; i<256; i++)
7901 {
7902 11520 tmp[i].r=r;
7903 11520 tmp[i].g=g;
7904 11520 tmp[i].b=b;
7905 11520 }
7906
7907 45 fade_interpolate(src,tmp,dest,pos,from,to);
7908 45 }
7909
7910 45 void system_pal()
7911 {
7912 45 is_sys_pal = true;
7913 static PALETTE pal;
7914 45 copy_pal((RGB*)datafile[PAL_GUI].dat, pal);
7915
7916 // set up the grayscale palette
7917
2/2
✓ Branch 0 taken 2880 times.
✓ Branch 1 taken 45 times.
2925 for(int32_t i=128; i<192; i++)
7918 {
7919 2880 pal[i].r = i-128;
7920 2880 pal[i].g = i-128;
7921 2880 pal[i].b = i-128;
7922 2880 }
7923 45 load_colorset(gui_colorset, pal, jwin_a5_colors);
7924
7925 45 color_layer(pal, pal, 24,16,16, 28, 128,191);
7926
7927
2/2
✓ Branch 0 taken 5760 times.
✓ Branch 1 taken 45 times.
5805 for(int32_t i=0; i<256; i+=2)
7928 {
7929 5760 int32_t v = (i>>3)+2;
7930 5760 int32_t c = (i>>3)+192;
7931 5760 pal[c] = _RGB(v,v,v+(v>>1));
7932 /*
7933 if(i<240)
7934 {
7935 _allegro_hline(tmp_scr,0,i,319,c);
7936 _allegro_hline(tmp_scr,0,i+1,319,c);
7937 }
7938 */
7939 5760 }
7940
7941 // draw the vertical screen gradient
7942
2/2
✓ Branch 0 taken 10800 times.
✓ Branch 1 taken 45 times.
10845 for(int32_t i=0; i<240; ++i)
7943 {
7944 10800 _allegro_hline(tmp_scr,0,i,319,192+(i*31/239));
7945 10800 }
7946
7947 /*
7948 palrstart= 10*63/255; palrend=166*63/255;
7949 palgstart= 36*63/255; palgend=202*63/255;
7950 palbstart=106*63/255; palbend=240*63/255;
7951 paldivs=32;
7952 for(int32_t i=0; i<paldivs; i++)
7953 {
7954 pal[223-paldivs+1+i].r = palrstart+((palrend-palrstart)*i/(paldivs-1));
7955 pal[223-paldivs+1+i].g = palgstart+((palgend-palgstart)*i/(paldivs-1));
7956 pal[223-paldivs+1+i].b = palbstart+((palbend-palbstart)*i/(paldivs-1));
7957 }
7958 */
7959 45 BITMAP *panorama = create_bitmap_ex(8,256,224);
7960 int32_t ts_height, ts_start;
7961
7962
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 45 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
45 if(tmpscr->flags3&fNOSUBSCR && !(tmpscr->flags3&fNOSUBSCROFFSET))
7963 {
7964 clear_to_color(panorama,0);
7965 blit(framebuf,panorama,0,playing_field_offset,0,28,256,224-passive_subscreen_height);
7966 ts_height=224-passive_subscreen_height;
7967 ts_start=28;
7968 }
7969 else
7970 {
7971 45 blit(framebuf,panorama,0,0,0,0,256,224);
7972 45 ts_height=224;
7973 45 ts_start=0;
7974 }
7975
7976 // gray scale the current frame
7977
2/2
✓ Branch 0 taken 10080 times.
✓ Branch 1 taken 45 times.
10125 for(int32_t y=0; y<ts_height; y++)
7978 {
7979
2/2
✓ Branch 0 taken 2580480 times.
✓ Branch 1 taken 10080 times.
2590560 for(int32_t x=0; x<256; x++)
7980 {
7981 2580480 int32_t c = panorama->line[y+ts_start][x];
7982
2/2
✓ Branch 0 taken 2574590 times.
✓ Branch 1 taken 5890 times.
2580480 int32_t gray = zc_min((RAMpal[c].r*42 + RAMpal[c].g*75 + RAMpal[c].b*14) >> 7, 63);
7983 2580480 tmp_scr->line[y+8+ts_start][x+32] = gray+128;
7984 2580480 }
7985 10080 }
7986
7987 45 destroy_bitmap(panorama);
7988
7989 // display everything
7990 45 vsync();
7991 45 hw_palette = &pal;
7992 45 update_hw_pal = true;
7993
7994 // sys_pal = pal;
7995 45 memcpy(sys_pal,pal,sizeof(pal));
7996 45 }
7997
7998 void system_pal2()
7999 {
8000 is_sys_pal = true;
8001 static PALETTE RAMpal2;
8002 copy_pal((RGB*)datafile[PAL_GUI].dat, RAMpal2);
8003
8004 /* Windows 2000 colors
8005 RAMpal2[dvc(1)] = _RGB( 0*63/255, 0*63/255, 0*63/255);
8006 RAMpal2[dvc(2)] = _RGB( 66*63/255, 65*63/255, 66*63/255);
8007 RAMpal2[dvc(3)] = _RGB(132*63/255, 130*63/255, 132*63/255);
8008 RAMpal2[dvc(4)] = _RGB(212*63/255, 208*63/255, 200*63/255);
8009 RAMpal2[dvc(5)] = _RGB(255*63/255, 255*63/255, 255*63/255);
8010 RAMpal2[dvc(6)] = _RGB(255*63/255, 255*63/255, 225*63/255);
8011 RAMpal2[dvc(7)] = _RGB(255*63/255, 225*63/255, 160*63/255);
8012 RAMpal2[dvc(8)] = _RGB( 0*63/255, 0*63/255, 80*63/255);
8013
8014 byte palrstart= 10*63/255, palrend=166*63/255,
8015 palgstart= 36*63/255, palgend=202*63/255,
8016 palbstart=106*63/255, palbend=240*63/255,
8017 paldivs=7;
8018 for(int32_t i=0; i<paldivs; i++)
8019 {
8020 RAMpal2[dvc(15-paldivs+1)+i].r = palrstart+((palrend-palrstart)*i/(paldivs-1));
8021 RAMpal2[dvc(15-paldivs+1)+i].g = palgstart+((palgend-palgstart)*i/(paldivs-1));
8022 RAMpal2[dvc(15-paldivs+1)+i].b = palbstart+((palbend-palbstart)*i/(paldivs-1));
8023 }
8024 */
8025
8026 /* Windows 98 colors
8027 RAMpal2[dvc(1)] = _RGB( 0*63/255, 0*63/255, 0*63/255);
8028 RAMpal2[dvc(2)] = _RGB(128*63/255, 128*63/255, 128*63/255);
8029 RAMpal2[dvc(3)] = _RGB(192*63/255, 192*63/255, 192*63/255);
8030 RAMpal2[dvc(4)] = _RGB(223*63/255, 223*63/255, 223*63/255);
8031 RAMpal2[dvc(5)] = _RGB(255*63/255, 255*63/255, 255*63/255);
8032 RAMpal2[dvc(6)] = _RGB(255*63/255, 255*63/255, 225*63/255);
8033 RAMpal2[dvc(7)] = _RGB(255*63/255, 225*63/255, 160*63/255);
8034 RAMpal2[dvc(8)] = _RGB( 0*63/255, 0*63/255, 80*63/255);
8035
8036 byte palrstart= 0*63/255, palrend=166*63/255,
8037 palgstart= 0*63/255, palgend=202*63/255,
8038 palbstart=128*63/255, palbend=240*63/255,
8039 paldivs=7;
8040 for(int32_t i=0; i<paldivs; i++)
8041 {
8042 RAMpal2[dvc(15-paldivs+1)+i].r = palrstart+((palrend-palrstart)*i/(paldivs-1));
8043 RAMpal2[dvc(15-paldivs+1)+i].g = palgstart+((palgend-palgstart)*i/(paldivs-1));
8044 RAMpal2[dvc(15-paldivs+1)+i].b = palbstart+((palbend-palbstart)*i/(paldivs-1));
8045 }
8046 */
8047
8048 /* Windows 99 colors
8049 RAMpal2[dvc(1)] = _RGB( 0*63/255, 0*63/255, 0*63/255);
8050 RAMpal2[dvc(2)] = _RGB( 64*63/255, 64*63/255, 64*63/255);
8051 RAMpal2[dvc(3)] = _RGB(128*63/255, 128*63/255, 128*63/255);
8052 RAMpal2[dvc(4)] = _RGB(192*63/255, 192*63/255, 192*63/255);
8053 RAMpal2[dvc(5)] = _RGB(223*63/255, 223*63/255, 223*63/255);
8054 RAMpal2[dvc(6)] = _RGB(255*63/255, 255*63/255, 255*63/255);
8055 RAMpal2[dvc(7)] = _RGB(255*63/255, 255*63/255, 225*63/255);
8056 RAMpal2[dvc(8)] = _RGB(255*63/255, 225*63/255, 160*63/255);
8057 RAMpal2[dvc(9)] = _RGB( 0*63/255, 0*63/255, 80*63/255);
8058
8059 byte palrstart= 0*63/255, palrend=166*63/255,
8060 palgstart= 0*63/255, palgend=202*63/255,
8061
8062 palbstart=128*63/255, palbend=240*63/255,
8063 paldivs=6;
8064 for(int32_t i=0; i<paldivs; i++)
8065 {
8066 RAMpal2[dvc(15-paldivs+1)+i].r = palrstart+((palrend-palrstart)*i/(paldivs-1));
8067 RAMpal2[dvc(15-paldivs+1)+i].g = palgstart+((palgend-palgstart)*i/(paldivs-1));
8068 RAMpal2[dvc(15-paldivs+1)+i].b = palbstart+((palbend-palbstart)*i/(paldivs-1));
8069 }
8070 */
8071
8072
8073
8074 RAMpal2[dvc(1)] = _RGB(0*63/255, 0*63/255, 0*63/255);
8075 RAMpal2[dvc(2)] = _RGB(64*63/255, 64*63/255, 64*63/255);
8076 RAMpal2[dvc(3)] = _RGB(128*63/255, 128*63/255, 128*63/255);
8077 RAMpal2[dvc(4)] = _RGB(192*63/255, 192*63/255, 192*63/255);
8078 RAMpal2[dvc(5)] = _RGB(223*63/255, 223*63/255, 223*63/255);
8079 RAMpal2[dvc(6)] = _RGB(255*63/255, 255*63/255, 255*63/255);
8080 RAMpal2[dvc(7)] = _RGB(255*63/255, 255*63/255, 225*63/255);
8081 RAMpal2[dvc(8)] = _RGB(255*63/255, 225*63/255, 160*63/255);
8082 RAMpal2[dvc(9)] = _RGB(0*63/255, 0*63/255, 80*63/255);
8083
8084 byte palrstart= 0*63/255, palrend=166*63/255,
8085 palgstart= 0*63/255, palgend=202*63/255,
8086 palbstart=128*63/255, palbend=240*63/255,
8087 paldivs=6;
8088
8089 for(int32_t i=0; i<paldivs; i++)
8090 {
8091 RAMpal2[dvc(15-paldivs+1)+i].r = palrstart+((palrend-palrstart)*i/(paldivs-1));
8092 RAMpal2[dvc(15-paldivs+1)+i].g = palgstart+((palgend-palgstart)*i/(paldivs-1));
8093 RAMpal2[dvc(15-paldivs+1)+i].b = palbstart+((palbend-palbstart)*i/(paldivs-1));
8094 }
8095
8096 gui_bg_color=jwin_pal[jcBOX];
8097 gui_fg_color=jwin_pal[jcBOXFG];
8098
8099 jwin_set_colors(jwin_pal);
8100
8101
8102 // set up the new palette
8103 for(int32_t i=128; i<192; i++)
8104 {
8105 RAMpal2[i].r = i-128;
8106 RAMpal2[i].g = i-128;
8107 RAMpal2[i].b = i-128;
8108 }
8109
8110 /*
8111 for(int32_t i=0; i<64; i++)
8112 {
8113 RAMpal2[128+i] = _RGB(i,i,i)1));
8114 }
8115 */
8116
8117 /*
8118
8119 pal[vc(1)] = _RGB(0x00,0x00,0x14);
8120 pal[vc(4)] = _RGB(0x36,0x36,0x36);
8121 pal[vc(6)] = _RGB(0x10,0x10,0x10);
8122 pal[vc(7)] = _RGB(0x20,0x20,0x20);
8123 pal[vc(9)] = _RGB(0x20,0x20,0x24);
8124 pal[vc(11)] = _RGB(0x30,0x30,0x30);
8125 pal[vc(14)] = _RGB(0x3F,0x38,0x28);
8126
8127 gui_fg_color=vc(14);
8128 gui_bg_color=vc(1);
8129
8130 jwin_set_colors(jwin_pal);
8131 */
8132
8133 // color_layer(RAMpal2, RAMpal2, 24,16,16, 28, 128,191);
8134
8135 // set up the colors for the vertical screen gradient
8136 for(int32_t i=0; i<256; i+=2)
8137 {
8138 int32_t v = (i>>3)+2;
8139 int32_t c = (i>>3)+192;
8140 RAMpal2[c] = _RGB(v,v,v+(v>>1));
8141
8142 /*
8143 if(i<240)
8144 {
8145 _allegro_hline(tmp_scr,0,i,319,c);
8146 _allegro_hline(tmp_scr,0,i+1,319,c);
8147 }
8148 */
8149 }
8150
8151 // hw_palette = &RAMpal;
8152 // update_hw_pal = true;
8153
8154 for(int32_t i=0; i<240; ++i)
8155 {
8156 _allegro_hline(tmp_scr,0,i,319,192+(i*31/239));
8157 }
8158
8159 /*
8160 byte palrstart= 10*63/255, palrend=166*63/255,
8161 palgstart= 36*63/255, palgend=202*63/255,
8162 palbstart=106*63/255, palbend=240*63/255,
8163 paldivs=32;
8164 for(int32_t i=0; i<paldivs; i++)
8165 {
8166 pal[223-paldivs+1+i].r = palrstart+((palrend-palrstart)*i/(paldivs-1));
8167 pal[223-paldivs+1+i].g = palgstart+((palgend-palgstart)*i/(paldivs-1));
8168 pal[223-paldivs+1+i].b = palbstart+((palbend-palbstart)*i/(paldivs-1));
8169 }
8170 */
8171 BITMAP *panorama = create_bitmap_ex(8,256,224);
8172 int32_t ts_height, ts_start;
8173
8174 if(tmpscr->flags3&fNOSUBSCR && !(tmpscr->flags3&fNOSUBSCROFFSET))
8175 {
8176 clear_to_color(panorama,0);
8177 blit(framebuf,panorama,0,playing_field_offset,0,28,256,224-passive_subscreen_height);
8178 ts_height=224-passive_subscreen_height;
8179 ts_start=28;
8180 }
8181 else
8182 {
8183 blit(framebuf,panorama,0,0,0,0,256,224);
8184 ts_height=224;
8185 ts_start=0;
8186 }
8187
8188 // gray scale the current frame
8189 for(int32_t y=0; y<ts_height; y++)
8190 {
8191 for(int32_t x=0; x<256; x++)
8192 {
8193 int32_t c = panorama->line[y+ts_start][x];
8194 int32_t gray = zc_min((RAMpal2[c].r*42 + RAMpal2[c].g*75 + RAMpal2[c].b*14) >> 7, 63);
8195 tmp_scr->line[y+8+ts_start][x+32] = gray+128;
8196 }
8197 }
8198
8199 destroy_bitmap(panorama);
8200
8201 // display everything
8202 vsync();
8203 hw_palette = &RAMpal2;
8204 update_hw_pal = true;
8205
8206 blit(tmp_scr,screen,0,0,scrx,scry,320,240);
8207
8208 // sys_pal = pal;
8209 memcpy(sys_pal,RAMpal2,sizeof(RAMpal2));
8210 }
8211
8212 static uint32_t entered_sys_pal = 0;
8213 14 void enter_sys_pal()
8214 {
8215
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(is_sys_pal)
8216 {
8217 if(entered_sys_pal)
8218 ++entered_sys_pal;
8219 return;
8220 }
8221 14 system_pal();
8222 14 ++entered_sys_pal;
8223 14 }
8224 14 void exit_sys_pal()
8225 {
8226
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(entered_sys_pal)
8227 {
8228
1/2
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
14 if(!--entered_sys_pal)
8229 {
8230 14 game_pal();
8231 14 }
8232 14 }
8233 14 }
8234
8235 void switch_out_callback()
8236 {
8237 if (pause_in_background)
8238 {
8239 callback_switchin = 3;
8240 return;
8241 }
8242
8243 #ifdef _WIN32
8244 if(midi_patch_fix==0 || currmidi==-1)
8245 return;
8246
8247
8248 paused_midi_pos = midi_pos;
8249 zc_stop_midi();
8250 midi_paused=true;
8251 midi_suspended = midissuspHALTED;
8252 #endif
8253 }
8254
8255 void switch_in_callback()
8256 {
8257 if(pause_in_background)
8258 {
8259 return;
8260 }
8261
8262 #ifdef _WIN32
8263 if(midi_patch_fix==0 || currmidi==-1)
8264 return;
8265
8266 else
8267 {
8268 callback_switchin = 1;
8269 midi_suspended = midissuspRESUME;
8270 }
8271 #endif
8272 }
8273
8274 279 void game_pal()
8275 {
8276 279 is_sys_pal = false;
8277 279 entered_sys_pal = 0;
8278 279 clear_to_color(screen,BLACK);
8279 279 hw_palette = &RAMpal;
8280 279 update_hw_pal = true;
8281 279 }
8282
8283 static char bar_str[] = "";
8284
8285 14 void music_pause()
8286 {
8287 //al_pause_duh(tmplayer);
8288 14 zcmusic_pause(zcmusic, ZCM_PAUSE);
8289 14 zc_midi_pause();
8290 14 midi_paused=true;
8291 14 }
8292
8293 void music_resume()
8294 {
8295 //al_resume_duh(tmplayer);
8296 zcmusic_pause(zcmusic, ZCM_RESUME);
8297 zc_midi_resume();
8298 midi_paused=false;
8299 }
8300
8301 5912 void music_stop()
8302 {
8303 //al_stop_duh(tmplayer);
8304 //unload_duh(tmusic);
8305 //tmusic=NULL;
8306 //tmplayer=NULL;
8307 5912 zcmusic_stop(zcmusic);
8308 5912 zcmusic_unload_file(zcmusic);
8309 5912 zc_stop_midi();
8310 5912 midi_paused=false;
8311 5912 currmidi=-1;
8312 5912 }
8313
8314 void System()
8315 {
8316 mouse_down=gui_mouse_b();
8317 music_pause();
8318 pause_all_sfx();
8319 MenuOpen = true;
8320 system_pal();
8321 // FONT *oldfont=font;
8322 // font=tfont;
8323
8324 misc_menu[2].flags =(isFullScreen()==1)?D_SELECTED:0;
8325 misc_menu[3].flags =(isFullScreen()==1)?D_DISABLED:0;
8326
8327 game_menu[2].flags = getsaveslot() > -1 ? 0 : D_DISABLED;
8328 #if DEVLEVEL > 1
8329 dev_menu[dv_setcheat].flags = Playing ? 0 : D_DISABLED;
8330 #endif
8331 game_menu[3].flags =
8332 misc_menu[5].flags = Playing ? 0 : D_DISABLED;
8333 misc_menu[7].flags = !Playing ? 0 : D_DISABLED;
8334 clear_keybuf();
8335
8336 DIALOG_PLAYER *p;
8337
8338 clear_bitmap(menu_bmp);
8339 oldscreen = screen;
8340 screen = menu_bmp;
8341
8342 p = init_dialog(system_dlg,-1);
8343
8344 // drop the menu on startup if menu button pressed
8345 if(joybtn(Mbtn)||zc_getrawkey(KEY_ESC))
8346 simulate_keypress(KEY_G << 8);
8347
8348 do
8349 {
8350 if(close_button_quit)
8351 {
8352 close_button_quit = false;
8353 f_Quit(qEXIT);
8354 if(Quit) break;
8355 }
8356 rest(17);
8357
8358 if(mouse_down && !gui_mouse_b())
8359 mouse_down=0;
8360
8361 title_menu[0].flags = (title_version==0) ? D_SELECTED : 0;
8362 title_menu[1].flags = (title_version==1) ? D_SELECTED : 0;
8363 title_menu[2].flags = (title_version==2) ? D_SELECTED : 0;
8364
8365 settings_menu[1].flags = replay_is_replaying() ? D_DISABLED : 0;
8366 settings_menu[5].flags = Throttlefps?D_SELECTED:0;
8367 settings_menu[6].flags = ShowFPS?D_SELECTED:0;
8368 settings_menu[7].flags = ClickToFreeze?D_SELECTED:0;
8369 settings_menu[9].flags = TransLayers?D_SELECTED:0;
8370 settings_menu[10].flags = NESquit?D_SELECTED:0;
8371 settings_menu[11].flags = volkeys?D_SELECTED:0;
8372
8373 window_menu[0].flags = DragAspect?D_SELECTED:0;
8374 window_menu[1].flags = scaleForceInteger?D_SELECTED:0;
8375 window_menu[2].flags = SaveDragResize?D_SELECTED:0;
8376 window_menu[3].flags = SaveWinPos?D_SELECTED:0;
8377 window_menu[4].flags = stretchGame?D_SELECTED:0;
8378
8379 options_menu[4].flags = (epilepsyFlashReduction) ? D_SELECTED : 0;
8380 options_menu[5].flags = (midi_patch_fix)?D_SELECTED:0;
8381
8382 name_entry_mode_menu[0].flags = (NameEntryMode==0)?D_SELECTED:0;
8383 name_entry_mode_menu[1].flags = (NameEntryMode==1)?D_SELECTED:0;
8384 name_entry_mode_menu[2].flags = (NameEntryMode==2)?D_SELECTED:0;
8385
8386 misc_menu[12].flags =(zasm_debugger)?D_SELECTED:0;
8387 misc_menu[13].flags =(zscript_debugger)?D_SELECTED:0;
8388 misc_menu[14].flags =(clearConsoleOnReload)?D_SELECTED:0;
8389 misc_menu[15].flags =(clearConsoleOnLoad)?D_SELECTED:0;
8390
8391 bool nocheat = (replay_is_replaying() || !Playing
8392 || (!zcheats.flags && !get_debug() && DEVLEVEL < 2 && !zqtesting_mode && !devpwd()));
8393 the_player_menu[2].flags = nocheat ? D_DISABLED : 0;
8394 cheat_menu[0].flags = 0;
8395 refill_menu[4].flags = get_bit(quest_rules, qr_TRUEARROWS) ? 0 : D_DISABLED;
8396 cheat_menu[1].text = (cheat >= 1) || get_debug() ? bar_str : NULL;
8397 cheat_menu[3].text = (cheat >= 2) || get_debug() ? bar_str : NULL;
8398 cheat_menu[8].text = (cheat >= 3) || get_debug() ? bar_str : NULL;
8399 cheat_menu[10].text = (cheat >= 4) || get_debug() ? bar_str : NULL;
8400 cheat_menu[4].flags = getClock() ? D_SELECTED : 0;
8401 cheat_menu[11].flags = toogam ? D_SELECTED : 0;
8402 cheat_menu[12].flags = ignoreSideview ? D_SELECTED : 0;
8403 cheat_menu[13].flags = gofast ? D_SELECTED : 0;
8404
8405 show_menu[0].flags = show_layer_0 ? D_SELECTED : 0;
8406 show_menu[1].flags = show_layer_1 ? D_SELECTED : 0;
8407 show_menu[2].flags = show_layer_2 ? D_SELECTED : 0;
8408 show_menu[3].flags = show_layer_3 ? D_SELECTED : 0;
8409 show_menu[4].flags = show_layer_4 ? D_SELECTED : 0;
8410 show_menu[5].flags = show_layer_5 ? D_SELECTED : 0;
8411 show_menu[6].flags = show_layer_6 ? D_SELECTED : 0;
8412 show_menu[7].flags = show_layer_over ? D_SELECTED : 0;
8413 show_menu[8].flags = show_layer_push ? D_SELECTED : 0;
8414 show_menu[9].flags = show_sprites ? D_SELECTED : 0;
8415 show_menu[10].flags = show_ffcs ? D_SELECTED : 0;
8416 show_menu[12].flags = show_walkflags ? D_SELECTED : 0;
8417 show_menu[13].flags = show_ff_scripts ? D_SELECTED : 0;
8418 show_menu[14].flags = show_hitboxes ? D_SELECTED : 0;
8419 show_menu[15].flags = show_effectflags ? D_SELECTED : 0;
8420
8421 settings_menu[8].flags = heart_beep ? D_SELECTED : 0;
8422 settings_menu[12].flags = use_save_indicator ? D_SELECTED : 0;
8423
8424 replay_menu[0].text = zc_get_config("zeldadx", "replay_new_saves", false) ?
8425 (char *)"Disable recording new saves" :
8426 (char *)"Enable recording new saves";
8427 replay_menu[1].flags = replay_is_active() ? 0 : D_DISABLED;
8428 replay_menu[1].text = replay_get_mode() == ReplayMode::Record ?
8429 (char *)"Stop recording" :
8430 (char *)"Stop replaying";
8431 replay_menu[5].flags = replay_get_mode() == ReplayMode::Record ? 0 : D_DISABLED;
8432 replay_menu[6].text = replay_is_snapshot_all_frames() ?
8433 (char *)"Disable snapshot all frames" :
8434 (char *)"Enable snapshot all frames";
8435
8436 reset_snapshot_format_menu();
8437 snapshot_format_menu[SnapshotFormat].flags = D_SELECTED;
8438
8439 if(debug_enabled)
8440 {
8441 settings_menu[14].flags = get_debug() ? D_SELECTED : 0;
8442 }
8443
8444 if(gui_mouse_b() && !mouse_down)
8445 break;
8446
8447 // press menu to drop the menu
8448 if(rMbtn())
8449 simulate_keypress(KEY_G << 8);
8450
8451 if(input_idle(true) > after_time())
8452 // run Screeen Saver
8453 {
8454 // Screen saver enabled for now.
8455 clear_keybuf();
8456 Matrix(ss_speed, ss_density, 0);
8457 system_pal();
8458 broadcast_dialog_message(MSG_DRAW, 0);
8459 }
8460
8461 update_hw_screen();
8462 }
8463 while(update_dialog(p));
8464
8465 screen = oldscreen;
8466
8467 // font=oldfont;
8468 mouse_down=gui_mouse_b();
8469 shutdown_dialog(p);
8470 MenuOpen = false;
8471 if(Quit)
8472 {
8473 kill_sfx();
8474 music_stop();
8475 update_hw_screen();
8476 }
8477 else
8478 {
8479 game_pal();
8480 music_resume();
8481 resume_all_sfx();
8482
8483 if(rc)
8484 ringcolor(false);
8485 }
8486
8487 eat_buttons();
8488
8489 rc=false;
8490 clear_keybuf();
8491 // text_mode(0);
8492 }
8493
8494 31 void fix_dialogs()
8495 {
8496 31 jwin_center_dialog(about_dlg);
8497 31 jwin_center_dialog(gamepad_dlg);
8498 31 jwin_center_dialog(credits_dlg);
8499 31 jwin_center_dialog(gamemode_dlg);
8500 31 jwin_center_dialog(getnum_dlg);
8501 31 jwin_center_dialog(goto_dlg);
8502 31 jwin_center_dialog(keyboard_control_dlg);
8503 31 jwin_center_dialog(midi_dlg);
8504 31 jwin_center_dialog(quest_dlg);
8505 31 jwin_center_dialog(scrsaver_dlg);
8506 31 jwin_center_dialog(sound_dlg);
8507 31 jwin_center_dialog(triforce_dlg);
8508
8509 // digi_dp[1] += scrx;
8510 // digi_dp[2] += scry;
8511 // midi_dp[1] += scrx;
8512 // midi_dp[2] += scry;
8513 // pan_dp[1] += scrx;
8514 // pan_dp[2] += scry;
8515 // emus_dp[1] += scrx;
8516 // emus_dp[2] += scry;
8517 // buf_dp[1] += scrx;
8518 // buf_dp[2] += scry;
8519 // sfx_dp[1] += scrx;
8520 // sfx_dp[2] += scry;
8521 31 }
8522
8523 /*****************************/
8524 /**** Custom Sound System ****/
8525 /*****************************/
8526
8527 2611 INLINE int32_t mixvol(int32_t v1,int32_t v2)
8528 {
8529
3/4
✓ Branch 0 taken 2353 times.
✓ Branch 1 taken 258 times.
✓ Branch 2 taken 2611 times.
✗ Branch 3 not taken.
2611 return (zc_min(v1,255)*zc_min(v2,255)) >> 8;
8530 }
8531
8532 // Run an NSF, or a MIDI if the NSF is missing somehow.
8533 93 bool try_zcmusic(char *filename, int32_t track, int32_t midi)
8534 {
8535 93 ZCMUSIC *newzcmusic = zcmusic_load_for_quest(filename, qstpath);
8536
8537 // Found it
8538
2/2
✓ Branch 0 taken 58 times.
✓ Branch 1 taken 35 times.
93 if(newzcmusic!=NULL)
8539 {
8540 58 zcmusic_stop(zcmusic);
8541 58 zcmusic_unload_file(zcmusic);
8542 58 zc_stop_midi();
8543
8544 58 zcmusic=newzcmusic;
8545 58 zcmusic_play(zcmusic, emusic_volume);
8546
8547
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 58 times.
58 if(track>0)
8548 58 zcmusic_change_track(zcmusic,track);
8549
8550 58 return true;
8551 }
8552
8553 // Not found, play MIDI - unless this was called by a script (yay, magic numbers)
8554
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 else if(midi>-1000)
8555 jukebox(midi);
8556
8557 35 return false;
8558 93 }
8559
8560 bool try_zcmusic_ex(char *filename, int32_t track, int32_t midi)
8561 {
8562 ZCMUSIC *newzcmusic = zcmusic_load_for_quest(filename, qstpath);
8563 // Found it
8564 if(newzcmusic!=NULL)
8565 {
8566 zcmusic_stop(zcmusic);
8567 zcmusic_unload_file(zcmusic);
8568 zc_stop_midi();
8569
8570 zcmusic=newzcmusic;
8571 zcmusic_play(zcmusic, emusic_volume);
8572
8573 if(track>0)
8574 zcmusic_change_track(zcmusic,track);
8575
8576 return true;
8577 }
8578
8579 // Not found, play MIDI - unless this was called by a script (yay, magic numbers)
8580 else if(midi>-1000)
8581 jukebox(midi);
8582
8583 return false;
8584 }
8585
8586 int32_t get_zcmusicpos()
8587 {
8588 int32_t debugtracething = zcmusic_get_curpos(zcmusic);
8589 return debugtracething;
8590 return 0;
8591 }
8592
8593 void set_zcmusicpos(int32_t position)
8594 {
8595 zcmusic_set_curpos(zcmusic, position);
8596 }
8597
8598 void set_zcmusicspeed(int32_t speed)
8599 {
8600 int32_t newspeed = vbound(speed, 0, 10000);
8601 zcmusic_set_speed(zcmusic, newspeed);
8602 }
8603
8604 1290 void jukebox(int32_t index,int32_t loop)
8605 {
8606 1290 music_stop();
8607
8608
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1290 times.
1290 if(index<0) index=MAXMIDIS-1;
8609
8610
1/2
✓ Branch 0 taken 1290 times.
✗ Branch 1 not taken.
1290 if(index>=MAXMIDIS) index=0;
8611
8612 1290 music_stop();
8613
8614 // Allegro's DIGMID driver (the one normally used on on Linux) gets
8615 // stuck notes when a song stops. This fixes it.
8616
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1290 times.
1290 if(strcmp(midi_driver->name, "DIGMID")==0)
8617 zc_set_volume(0, 0);
8618
8619 1290 zc_set_volume(-1, mixvol(tunes[index].volume,midi_volume>>1));
8620 1290 zc_play_midi((MIDI*)tunes[index].data,loop);
8621
8622
2/2
✓ Branch 0 taken 910 times.
✓ Branch 1 taken 380 times.
1290 if(tunes[index].start>0)
8623 380 zc_midi_seek(tunes[index].start);
8624
8625 1290 midi_loop_start = tunes[index].loop_start;
8626 1290 midi_loop_end = tunes[index].loop_end;
8627
8628 1290 currmidi=index;
8629 1290 master_volume(digi_volume,midi_volume);
8630 1290 midi_paused=false;
8631 1290 }
8632
8633 10509 void jukebox(int32_t index)
8634 {
8635
1/2
✓ Branch 0 taken 10509 times.
✗ Branch 1 not taken.
10509 if(index<0) index=MAXMIDIS-1;
8636
8637
1/2
✓ Branch 0 taken 10509 times.
✗ Branch 1 not taken.
10509 if(index>=MAXMIDIS) index=0;
8638
8639 // do nothing if it's already playing
8640
3/4
✓ Branch 0 taken 9219 times.
✓ Branch 1 taken 1290 times.
✓ Branch 2 taken 9219 times.
✗ Branch 3 not taken.
10509 if(index==currmidi && midi_pos>=0)
8641 {
8642 9219 midi_paused=false;
8643 9219 return;
8644 }
8645
8646 1290 jukebox(index,tunes[index].loop);
8647 10509 }
8648
8649 11749 void play_DmapMusic()
8650 {
8651 static char tfile[2048];
8652 static int32_t ttrack=0;
8653 11749 bool domidi=false;
8654
8655
2/2
✓ Branch 0 taken 1330 times.
✓ Branch 1 taken 10419 times.
11749 if(DMaps[currdmap].tmusic[0]!=0)
8656 {
8657
3/4
✓ Branch 0 taken 385 times.
✓ Branch 1 taken 945 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 385 times.
1715 if(zcmusic==NULL ||
8658
1/2
✓ Branch 0 taken 385 times.
✗ Branch 1 not taken.
385 strcmp(zcmusic->filename,DMaps[currdmap].tmusic)!=0 ||
8659
1/2
✓ Branch 0 taken 385 times.
✗ Branch 1 not taken.
385 (zcmusic->type==ZCMF_GME && zcmusic->track != DMaps[currdmap].tmusictrack))
8660 {
8661
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 945 times.
945 if(zcmusic != NULL)
8662 {
8663 zcmusic_stop(zcmusic);
8664 zcmusic_unload_file(zcmusic);
8665 zcmusic = NULL;
8666 }
8667
8668 945 zcmusic = zcmusic_load_for_quest(DMaps[currdmap].tmusic, qstpath);
8669
8670
2/2
✓ Branch 0 taken 86 times.
✓ Branch 1 taken 859 times.
945 if(zcmusic!=NULL)
8671 {
8672 86 zc_stop_midi();
8673 86 strcpy(tfile,DMaps[currdmap].tmusic);
8674 86 zcmusic_play(zcmusic, emusic_volume);
8675 86 int32_t temptracks=0;
8676 86 temptracks=zcmusic_get_tracks(zcmusic);
8677
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 86 times.
86 temptracks=(temptracks<2)?1:temptracks;
8678 86 ttrack = vbound(DMaps[currdmap].tmusictrack,0,temptracks-1);
8679 86 zcmusic_change_track(zcmusic,ttrack);
8680 86 }
8681 else
8682 {
8683 859 tfile[0] = 0;
8684 859 domidi=true;
8685 }
8686 945 }
8687 1330 }
8688 else
8689 {
8690 10419 domidi=true;
8691 }
8692
8693
2/2
✓ Branch 0 taken 471 times.
✓ Branch 1 taken 11278 times.
11749 if(domidi)
8694 {
8695 11278 int32_t m=DMaps[currdmap].midi;
8696
8697
3/4
✓ Branch 0 taken 11144 times.
✓ Branch 1 taken 105 times.
✓ Branch 2 taken 29 times.
✗ Branch 3 not taken.
11278 switch(m)
8698 {
8699 case 1:
8700 105 jukebox(ZC_MIDI_OVERWORLD);
8701 105 break;
8702
8703 case 2:
8704 29 jukebox(ZC_MIDI_DUNGEON);
8705 29 break;
8706
8707 case 3:
8708 jukebox(ZC_MIDI_LEVEL9);
8709 break;
8710
8711 default:
8712
3/4
✓ Branch 0 taken 10226 times.
✓ Branch 1 taken 918 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 10226 times.
11144 if(m>=4 && m<4+MAXCUSTOMMIDIS)
8713 10226 jukebox(m+MIDIOFFSET_DMAP);
8714 else
8715 918 music_stop();
8716 11144 }
8717 11278 }
8718 11749 }
8719
8720 11786 void playLevelMusic()
8721 {
8722 11786 int32_t m=tmpscr->screen_midi;
8723
8724
3/6
✓ Branch 0 taken 11733 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 41 times.
✓ Branch 4 taken 12 times.
✗ Branch 5 not taken.
11786 switch(m)
8725 {
8726 case -2:
8727 12 music_stop();
8728 12 break;
8729
8730 case -1:
8731 11733 play_DmapMusic();
8732 11733 break;
8733
8734 case 1:
8735 jukebox(ZC_MIDI_OVERWORLD);
8736 break;
8737
8738 case 2:
8739 jukebox(ZC_MIDI_DUNGEON);
8740 break;
8741
8742 case 3:
8743 jukebox(ZC_MIDI_LEVEL9);
8744 break;
8745
8746 default:
8747
2/4
✓ Branch 0 taken 41 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 41 times.
✗ Branch 3 not taken.
41 if(m>=4 && m<4+MAXCUSTOMMIDIS)
8748 41 jukebox(m+MIDIOFFSET_MAPSCR);
8749 else
8750 music_stop();
8751 41 }
8752 11786 }
8753
8754 1321 void master_volume(int32_t dv,int32_t mv)
8755 {
8756
4/8
✗ Branch 0 not taken.
✓ Branch 1 taken 1321 times.
✓ Branch 2 taken 1321 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1321 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1321 times.
✗ Branch 7 not taken.
1321 if(dv>=0) digi_volume=zc_max(zc_min(dv,255),0);
8757
8758
4/8
✗ Branch 0 not taken.
✓ Branch 1 taken 1321 times.
✓ Branch 2 taken 1321 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1321 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1321 times.
✗ Branch 7 not taken.
1321 if(mv>=0) midi_volume=zc_max(zc_min(mv,255),0);
8759
8760
6/6
✓ Branch 0 taken 1286 times.
✓ Branch 1 taken 35 times.
✓ Branch 2 taken 1319 times.
✓ Branch 3 taken 2 times.
✓ Branch 4 taken 1284 times.
✓ Branch 5 taken 35 times.
1321 int32_t i = zc_min(zc_max(currmidi,0),MAXMIDIS-1);
8761 1321 zc_set_volume(digi_volume,mixvol(tunes[i].volume,midi_volume));
8762 1321 }
8763
8764 /*****************/
8765 /***** SFX *****/
8766 /*****************/
8767
8768 // array of voices, one for each sfx sample in the data file
8769 // 0+ = voice #
8770 // -1 = voice not allocated
8771 31 void Z_init_sound()
8772 {
8773
2/2
✓ Branch 0 taken 7936 times.
✓ Branch 1 taken 31 times.
7967 for(int32_t i=0; i<WAV_COUNT; i++)
8774 7936 sfx_voice[i]=-1;
8775
8776
2/2
✓ Branch 0 taken 217 times.
✓ Branch 1 taken 31 times.
248 for(int32_t i=0; i<ZC_MIDI_COUNT; i++)
8777 217 tunes[i].data = (MIDI*)mididata[i].dat;
8778
8779
2/2
✓ Branch 0 taken 7812 times.
✓ Branch 1 taken 31 times.
7843 for(int32_t j=0; j<MAXCUSTOMMIDIS; j++)
8780 7812 tunes[ZC_MIDI_COUNT+j].data=NULL;
8781
8782 31 master_volume(digi_volume,midi_volume);
8783 31 }
8784
8785 // returns number of voices currently allocated
8786 int32_t sfx_count()
8787 {
8788 int32_t c=0;
8789
8790 for(int32_t i=0; i<WAV_COUNT; i++)
8791 if(sfx_voice[i]!=-1)
8792 ++c;
8793
8794 return c;
8795 }
8796
8797 // clean up finished samples
8798 7481008 void sfx_cleanup()
8799 {
8800
2/2
✓ Branch 0 taken 1915138048 times.
✓ Branch 1 taken 7481008 times.
1922619056 for(int32_t i=0; i<WAV_COUNT; i++)
8801
3/4
✓ Branch 0 taken 614039 times.
✓ Branch 1 taken 1914524009 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 614039 times.
1915752087 if(sfx_voice[i]!=-1 && voice_get_position(sfx_voice[i])<0)
8802 {
8803 614039 deallocate_voice(sfx_voice[i]);
8804 614039 sfx_voice[i]=-1;
8805 614039 }
8806 7481008 }
8807
8808 // allocates a voice for the sample "wav_index" (index into zelda.dat)
8809 // if a voice is already allocated (and/or playing), then it just returns true
8810 // Returns true: voice is allocated
8811 // false: unsuccessful
8812 944287 bool sfx_init(int32_t index)
8813 {
8814 // check index
8815
3/4
✓ Branch 0 taken 681606 times.
✓ Branch 1 taken 262681 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 681606 times.
944287 if(index<=0 || index>=WAV_COUNT)
8816 262681 return false;
8817
8818
2/2
✓ Branch 0 taken 67541 times.
✓ Branch 1 taken 614065 times.
681606 if(sfx_voice[index]==-1)
8819 {
8820
2/2
✓ Branch 0 taken 163578 times.
✓ Branch 1 taken 450487 times.
614065 if(sfxdat)
8821 {
8822
1/2
✓ Branch 0 taken 163578 times.
✗ Branch 1 not taken.
163578 if(index<Z35)
8823 {
8824 163578 sfx_voice[index]=allocate_voice((SAMPLE*)sfxdata[index].dat);
8825 163578 }
8826 else
8827 {
8828 sfx_voice[index]=allocate_voice((SAMPLE*)sfxdata[Z35].dat);
8829 }
8830 163578 }
8831 else
8832 {
8833 450487 sfx_voice[index]=allocate_voice(&customsfxdata[index]);
8834 }
8835
8836 614065 voice_set_volume(sfx_voice[index], sfx_volume);
8837 614065 }
8838
8839 681606 return sfx_voice[index] != -1;
8840 944287 }
8841
8842 // plays an sfx sample
8843 801188 void sfx(int32_t index,int32_t pan,bool loop, bool restart)
8844 {
8845
2/2
✓ Branch 0 taken 608323 times.
✓ Branch 1 taken 192865 times.
801188 if(!sfx_init(index))
8846 192865 return;
8847
8848 608323 voice_set_playmode(sfx_voice[index],loop?PLAYMODE_LOOP:PLAYMODE_PLAY);
8849 608323 voice_set_pan(sfx_voice[index],pan);
8850
8851 608323 int32_t pos = voice_get_position(sfx_voice[index]);
8852
8853
2/2
✓ Branch 0 taken 288965 times.
✓ Branch 1 taken 319358 times.
608323 if(restart) voice_set_position(sfx_voice[index],0);
8854
8855
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 608323 times.
608323 if(pos<=0)
8856 608323 voice_start(sfx_voice[index]);
8857
8858
3/4
✓ Branch 0 taken 319358 times.
✓ Branch 1 taken 288965 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 319358 times.
608323 if (restart && replay_is_debug())
8859
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 319358 times.
319358 replay_step_comment(fmt::format("sfx {}", sfx_string[index]));
8860 801188 }
8861
8862 // true if sfx is allocated
8863 34070 bool sfx_allocated(int32_t index)
8864 {
8865
3/4
✓ Branch 0 taken 9405 times.
✓ Branch 1 taken 24665 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 9405 times.
34070 return (index>0 && index<WAV_COUNT && sfx_voice[index]!=-1);
8866 }
8867
8868 // start it (in loop mode) if it's not already playing,
8869 // otherwise adjust it to play in loop mode -DD
8870 143099 void cont_sfx(int32_t index)
8871 {
8872
2/2
✓ Branch 0 taken 69816 times.
✓ Branch 1 taken 73283 times.
143099 if(!sfx_init(index))
8873 {
8874 69816 return;
8875 }
8876
8877
1/2
✓ Branch 0 taken 73283 times.
✗ Branch 1 not taken.
73283 if(voice_get_position(sfx_voice[index])<=0)
8878 {
8879 73283 voice_set_position(sfx_voice[index],0);
8880 73283 voice_set_playmode(sfx_voice[index],PLAYMODE_LOOP);
8881 73283 voice_start(sfx_voice[index]);
8882 73283 }
8883 else
8884 {
8885 adjust_sfx(index, 128, true);
8886 }
8887 143099 }
8888
8889 // adjust parameters while playing
8890 3829 void adjust_sfx(int32_t index,int32_t pan,bool loop)
8891 {
8892
5/6
✓ Branch 0 taken 2170 times.
✓ Branch 1 taken 1659 times.
✓ Branch 2 taken 2170 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 14 times.
✓ Branch 5 taken 2156 times.
3829 if(index<=0 || index>=WAV_COUNT || sfx_voice[index]==-1)
8893 3815 return;
8894
8895 14 voice_set_playmode(sfx_voice[index],loop?PLAYMODE_LOOP:PLAYMODE_PLAY);
8896 14 voice_set_pan(sfx_voice[index],pan);
8897 3829 }
8898
8899 // pauses a voice
8900 1593 void pause_sfx(int32_t index)
8901 {
8902
3/6
✓ Branch 0 taken 1593 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1593 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1593 times.
1593 if(index>0 && index<WAV_COUNT && sfx_voice[index]!=-1)
8903 voice_stop(sfx_voice[index]);
8904 1593 }
8905
8906 // resumes a voice
8907 688 void resume_sfx(int32_t index)
8908 {
8909
3/6
✓ Branch 0 taken 688 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 688 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 688 times.
688 if(index>0 && index<WAV_COUNT && sfx_voice[index]!=-1)
8910 voice_start(sfx_voice[index]);
8911 688 }
8912
8913 // pauses all active voices
8914 296 void pause_all_sfx()
8915 {
8916
2/2
✓ Branch 0 taken 75776 times.
✓ Branch 1 taken 296 times.
76072 for(int32_t i=0; i<WAV_COUNT; i++)
8917
2/2
✓ Branch 0 taken 75774 times.
✓ Branch 1 taken 2 times.
75778 if(sfx_voice[i]!=-1)
8918 2 voice_stop(sfx_voice[i]);
8919 296 }
8920
8921 // resumes all paused voices
8922 282 void resume_all_sfx()
8923 {
8924
2/2
✓ Branch 0 taken 72192 times.
✓ Branch 1 taken 282 times.
72474 for(int32_t i=0; i<WAV_COUNT; i++)
8925
1/2
✓ Branch 0 taken 72192 times.
✗ Branch 1 not taken.
72192 if(sfx_voice[i]!=-1)
8926 voice_start(sfx_voice[i]);
8927 282 }
8928
8929 // stops an sfx and deallocates the voice
8930 6023527 void stop_sfx(int32_t index)
8931 {
8932
3/4
✓ Branch 0 taken 5267427 times.
✓ Branch 1 taken 756100 times.
✓ Branch 2 taken 5267427 times.
✗ Branch 3 not taken.
6023527 if(index<=0 || index>=WAV_COUNT)
8933 756100 return;
8934
8935
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 5267414 times.
5267427 if(sfx_voice[index]!=-1)
8936 {
8937 13 deallocate_voice(sfx_voice[index]);
8938 13 sfx_voice[index]=-1;
8939 13 }
8940 6023527 }
8941
8942 // Stops SFX played by Hero's item of the given family
8943 131275 void stop_item_sfx(int32_t family)
8944 {
8945 131275 int32_t id=current_item_id(family);
8946
8947
2/2
✓ Branch 0 taken 130875 times.
✓ Branch 1 taken 400 times.
131275 if(id<0)
8948 130875 return;
8949
8950 400 stop_sfx(itemsbuf[id].usesound);
8951 131275 }
8952
8953 2106 void kill_sfx()
8954 {
8955
2/2
✓ Branch 0 taken 539136 times.
✓ Branch 1 taken 2106 times.
541242 for(int32_t i=0; i<WAV_COUNT; i++)
8956
2/2
✓ Branch 0 taken 539123 times.
✓ Branch 1 taken 13 times.
539149 if(sfx_voice[i]!=-1)
8957 {
8958 13 deallocate_voice(sfx_voice[i]);
8959 13 sfx_voice[i]=-1;
8960 13 }
8961 2106 }
8962
8963 561327 int32_t pan(int32_t x)
8964 {
8965
1/4
✓ Branch 0 taken 561327 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
561327 switch(pan_style)
8966 {
8967 case 0:
8968 return 128;
8969
8970 case 1:
8971 561327 return vbound((x>>1)+68,0,255);
8972
8973 case 2:
8974 return vbound(((x*3)>>2)+36,0,255);
8975 }
8976
8977 return vbound(x,0,255);
8978 561327 }
8979
8980 /*******************************/
8981 /******* Input Handlers ********/
8982 /*******************************/
8983
8984 19693871 bool joybtn(int32_t b)
8985 {
8986
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 19693871 times.
19693871 if(b == 0)
8987 return false;
8988
8989 19693871 return joy[joystick_index].button[b-1].b !=0;
8990 19693871 }
8991
8992 const char* joybtn_name(int32_t b)
8993 {
8994 if(b == 0)
8995 return "";
8996
8997 return joy[joystick_index].button[b-1].name;
8998 }
8999
9000 int32_t next_press_key();
9001
9002 int32_t next_press_btn()
9003 {
9004 clear_keybuf();
9005 /*bool b[joy[joystick_index].num_buttons+1];
9006
9007 for(int32_t i=1; i<=joy[joystick_index].num_buttons; i++)
9008 b[i]=joybtn(i);*/
9009
9010 //first, we need to wait until they're pressing no buttons
9011 for(;;)
9012 {
9013 if(keypressed())
9014 {
9015 switch(readkey()>>8)
9016 {
9017 case KEY_ESC:
9018 return -1;
9019
9020 case KEY_SPACE:
9021 return 0;
9022 }
9023 }
9024
9025 poll_joystick();
9026 bool done = true;
9027
9028 for(int32_t i=1; i<=joy[joystick_index].num_buttons; i++)
9029 {
9030 if(joybtn(i)) done = false;
9031 }
9032
9033 if(done) break;
9034 rest(1);
9035 }
9036
9037 //now, we need to wait for them to press any button
9038 for(;;)
9039 {
9040 if(keypressed())
9041 {
9042 switch(readkey()>>8)
9043 {
9044 case KEY_ESC:
9045 return -1;
9046
9047 case KEY_SPACE:
9048 return 0;
9049 }
9050 }
9051
9052 poll_joystick();
9053
9054 for(int32_t i=1; i<=joy[joystick_index].num_buttons; i++)
9055 {
9056 if(joybtn(i)) return i;
9057 }
9058 rest(1);
9059 }
9060 }
9061
9062 155827264 static bool rButton(bool &btn, bool &flag, bool* rawbtn = nullptr)
9063 {
9064
2/2
✓ Branch 0 taken 150362686 times.
✓ Branch 1 taken 5464578 times.
155827264 bool ret = btn && !flag;
9065
2/2
✓ Branch 0 taken 132992741 times.
✓ Branch 1 taken 22834523 times.
155827264 flag = rawbtn ? *rawbtn : btn;
9066
9067 155827264 return ret;
9068 }
9069 1431671 static bool rButtonPeek(bool btn, bool flag)
9070 {
9071
2/2
✓ Branch 0 taken 1339943 times.
✓ Branch 1 taken 91728 times.
1431671 if(!btn)
9072 {
9073 1339943 return false;
9074 }
9075
2/2
✓ Branch 0 taken 15558 times.
✓ Branch 1 taken 76170 times.
91728 else if(!flag)
9076 {
9077 15558 return true;
9078 }
9079
9080 76170 return false;
9081 1431671 }
9082
9083 // Updated only by keyboard/gamepad.
9084 // If in replay mode, this is set directly by the replay system.
9085 // This should never be read from directly - use control_state instead.
9086 bool raw_control_state[ZC_CONTROL_STATES];
9087
9088 // Every call to load_control_state (pretty much every frame) resets this to be equal to raw_control_state.
9089 // This state can drift from raw_control_state if button states are "eaten" or overriden by a script. But that only
9090 // lasts until the next call to load_control_state.
9091 bool control_state[ZC_CONTROL_STATES];
9092 bool disable_control[ZC_CONTROL_STATES];
9093 bool drunk_toggle_state[11];
9094 bool disabledKeys[127];
9095 bool KeyInput[127];
9096 bool KeyPress[127];
9097
9098 bool key_current_frame[127];
9099 bool key_previous_frame[127];
9100
9101 static bool key_system[127];
9102 static bool key_system_previous[127];
9103 static bool key_system_press[127];
9104
9105 bool button_press[ZC_CONTROL_STATES];
9106 bool button_hold[ZC_CONTROL_STATES];
9107
9108 #define STICK_1_X joy[joystick_index].stick[js_stick_1_x_stick].axis[js_stick_1_x_axis]
9109 #define STICK_1_Y joy[joystick_index].stick[js_stick_1_y_stick].axis[js_stick_1_y_axis]
9110 #define STICK_2_X joy[joystick_index].stick[js_stick_2_x_stick].axis[js_stick_2_x_axis]
9111 #define STICK_2_Y joy[joystick_index].stick[js_stick_2_y_stick].axis[js_stick_2_y_axis]
9112 #define STICK_PRECISION 56 //define your own sensitivity
9113
9114 6294842 void load_control_state()
9115 {
9116 6294842 load_control_called_this_frame = true;
9117
9118
4/4
✓ Branch 0 taken 3423641 times.
✓ Branch 1 taken 2871201 times.
✓ Branch 2 taken 856645 times.
✓ Branch 3 taken 2566996 times.
6294842 if (replay_get_version() >= 8 && replay_get_version() < 11)
9119 {
9120
2/2
✓ Branch 0 taken 46205928 times.
✓ Branch 1 taken 2566996 times.
48772924 for (int i = 0; i < ZC_CONTROL_STATES; i++)
9121 46205928 down_control_states[i] = raw_control_state[i];
9122 2566996 }
9123
9124
1/2
✓ Branch 0 taken 6294842 times.
✗ Branch 1 not taken.
6294842 if (!replay_is_replaying())
9125 {
9126 raw_control_state[0]=zc_getrawkey(DUkey, true)||(analog_movement ? STICK_1_Y.d1 || STICK_1_Y.pos - js_stick_1_y_offset < -STICK_PRECISION : joybtn(DUbtn));
9127 raw_control_state[1]=zc_getrawkey(DDkey, true)||(analog_movement ? STICK_1_Y.d2 || STICK_1_Y.pos - js_stick_1_y_offset > STICK_PRECISION : joybtn(DDbtn));
9128 raw_control_state[2]=zc_getrawkey(DLkey, true)||(analog_movement ? STICK_1_X.d1 || STICK_1_X.pos - js_stick_1_x_offset < -STICK_PRECISION : joybtn(DLbtn));
9129 raw_control_state[3]=zc_getrawkey(DRkey, true)||(analog_movement ? STICK_1_X.d2 || STICK_1_X.pos - js_stick_1_x_offset > STICK_PRECISION : joybtn(DRbtn));
9130 raw_control_state[4]=zc_getrawkey(Akey, true)||joybtn(Abtn);
9131 raw_control_state[5]=zc_getrawkey(Bkey, true)||joybtn(Bbtn);
9132 raw_control_state[6]=zc_getrawkey(Skey, true)||joybtn(Sbtn);
9133 raw_control_state[7]=zc_getrawkey(Lkey, true)||joybtn(Lbtn);
9134 raw_control_state[8]=zc_getrawkey(Rkey, true)||joybtn(Rbtn);
9135 raw_control_state[9]=zc_getrawkey(Pkey, true)||joybtn(Pbtn);
9136 raw_control_state[10]=zc_getrawkey(Exkey1, true)||joybtn(Exbtn1);
9137 raw_control_state[11]=zc_getrawkey(Exkey2, true)||joybtn(Exbtn2);
9138 raw_control_state[12]=zc_getrawkey(Exkey3, true)||joybtn(Exbtn3);
9139 raw_control_state[13]=zc_getrawkey(Exkey4, true)||joybtn(Exbtn4);
9140
9141 if(num_joysticks != 0)
9142 {
9143 raw_control_state[14] = STICK_2_Y.pos - js_stick_2_y_offset < -STICK_PRECISION;
9144 raw_control_state[15] = STICK_2_Y.pos - js_stick_2_y_offset > STICK_PRECISION;
9145 raw_control_state[16] = STICK_2_X.pos - js_stick_2_x_offset < -STICK_PRECISION;
9146 raw_control_state[17] = STICK_2_X.pos - js_stick_2_x_offset > STICK_PRECISION;
9147 // zprint2("Detected %d joysticks... %d%d%d%d\n", num_joysticks, raw_control_state[14]?1:0, raw_control_state[15]?1:0, raw_control_state[16]?1:0, raw_control_state[17]?1:0);
9148 }
9149 else
9150 {
9151 raw_control_state[14] = false;
9152 raw_control_state[15] = false;
9153 raw_control_state[16] = false;
9154 raw_control_state[17] = false;
9155 // zprint2("Detected 0 joysticks... clearing inputaxis values.\n");
9156 }
9157 bool did_bad_cutscene_btn = false;
9158 for(int q = 0; q < 18; ++q)
9159 if(raw_control_state[q] && !active_cutscene.can_button(q))
9160 {
9161 raw_control_state[q] = false;
9162 did_bad_cutscene_btn = true;
9163 }
9164 if(did_bad_cutscene_btn)
9165 active_cutscene.error();
9166 }
9167
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 6294839 times.
6294842 if (replay_is_active())
9168 {
9169
2/2
✓ Branch 0 taken 1015215 times.
✓ Branch 1 taken 5279624 times.
6294839 if (replay_get_version() < 3)
9170 1015215 replay_poll();
9171
3/4
✓ Branch 0 taken 5279624 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3518249 times.
✓ Branch 3 taken 1761375 times.
5279624 else if (replay_is_replaying() && replay_get_version() < 6)
9172 1761375 replay_peek_input();
9173
5/6
✓ Branch 0 taken 3518249 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3423641 times.
✓ Branch 3 taken 94608 times.
✓ Branch 4 taken 856645 times.
✓ Branch 5 taken 2566996 times.
3518249 else if (replay_is_replaying() && replay_get_version() >= 8 && replay_get_version() < 11)
9174 2566996 replay_peek_input();
9175
2/2
✓ Branch 0 taken 5177373 times.
✓ Branch 1 taken 1117466 times.
6294839 if (replay_get_version() == 8)
9176 1117466 update_keys();
9177 6294839 }
9178
9179 // Some test replay files were made before a serious input bug was fixed, so instead
9180 // of re-doing them or tossing them out, just check for that zplay version.
9181
3/4
✓ Branch 0 taken 6294836 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 121900 times.
✓ Branch 3 taken 6172936 times.
6294842 bool botched_input = replay_is_active() && replay_get_version() != 1 && replay_get_version() < 8;
9182
2/2
✓ Branch 0 taken 113307048 times.
✓ Branch 1 taken 6294836 times.
119601884 for (int i = 0; i < ZC_CONTROL_STATES; i++)
9183 {
9184 113307048 control_state[i] = raw_control_state[i];
9185
4/4
✓ Branch 0 taken 49487310 times.
✓ Branch 1 taken 63819738 times.
✓ Branch 2 taken 2410168 times.
✓ Branch 3 taken 47077142 times.
113307048 if (botched_input && !control_state[i])
9186 47077142 down_control_states[i] = false;
9187 113307048 }
9188
9189 6294836 button_press[0]=rButton(control_state[0],button_hold[0]);
9190 6294836 button_press[1]=rButton(control_state[1],button_hold[1]);
9191 6294836 button_press[2]=rButton(control_state[2],button_hold[2]);
9192 6294836 button_press[3]=rButton(control_state[3],button_hold[3]);
9193 6294836 button_press[4]=rButton(control_state[4],button_hold[4]);
9194 6294836 button_press[5]=rButton(control_state[5],button_hold[5]);
9195 6294836 button_press[6]=rButton(control_state[6],button_hold[6]);
9196 6294836 button_press[7]=rButton(control_state[7],button_hold[7]);
9197 6294836 button_press[8]=rButton(control_state[8],button_hold[8]);
9198 6294836 button_press[9]=rButton(control_state[9],button_hold[9]);
9199 6294836 button_press[10]=rButton(control_state[10],button_hold[10]);
9200 6294836 button_press[11]=rButton(control_state[11],button_hold[11]);
9201 6294836 button_press[12]=rButton(control_state[12],button_hold[12]);
9202 6294836 button_press[13]=rButton(control_state[13],button_hold[13]);
9203 6294836 button_press[14]=rButton(control_state[14],button_hold[14]);
9204 6294836 button_press[15]=rButton(control_state[15],button_hold[15]);
9205 6294836 button_press[16]=rButton(control_state[16],button_hold[16]);
9206 6294836 button_press[17]=rButton(control_state[17],button_hold[17]);
9207 6294836 }
9208
9209 // Returns true if any game key is pressed. This is needed because keypressed()
9210 // doesn't detect modifier keys and control_state[] can be modified by scripts.
9211 32575662 bool zc_key_pressed()
9212 //may also need to use zc_getrawkey
9213 {
9214
7/10
✓ Branch 0 taken 26367901 times.
✓ Branch 1 taken 6207761 times.
✓ Branch 2 taken 6207761 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 6207761 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 5218286 times.
✓ Branch 7 taken 5218286 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 1928083 times.
34503745 if((zc_getrawkey(DUkey, true)||(analog_movement ? STICK_1_Y.d1 || STICK_1_Y.pos - js_stick_1_y_offset< -STICK_PRECISION : joybtn(DUbtn))) ||
9215
4/6
✓ Branch 0 taken 5218286 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5218286 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3932854 times.
✓ Branch 5 taken 3932854 times.
5218286 (zc_getrawkey(DDkey, true)||(analog_movement ? STICK_1_Y.d2 || STICK_1_Y.pos - js_stick_1_y_offset > STICK_PRECISION : joybtn(DDbtn))) ||
9216
4/6
✓ Branch 0 taken 3932854 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3932854 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2522346 times.
✓ Branch 5 taken 2522346 times.
3932854 (zc_getrawkey(DLkey, true)||(analog_movement ? STICK_1_X.d1 || STICK_1_X.pos - js_stick_1_x_offset < -STICK_PRECISION : joybtn(DLbtn))) ||
9217
4/6
✓ Branch 0 taken 2522346 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2522346 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2167516 times.
✓ Branch 5 taken 2167516 times.
2522346 (zc_getrawkey(DRkey, true)||(analog_movement ? STICK_1_X.d2 || STICK_1_X.pos - js_stick_1_x_offset > STICK_PRECISION : joybtn(DRbtn))) ||
9218
1/2
✓ Branch 0 taken 2167516 times.
✗ Branch 1 not taken.
2167516 (zc_getrawkey(Akey, true)||joybtn(Abtn)) ||
9219
3/4
✓ Branch 0 taken 2054751 times.
✓ Branch 1 taken 112765 times.
✓ Branch 2 taken 2054751 times.
✗ Branch 3 not taken.
2167516 (zc_getrawkey(Bkey, true)||joybtn(Bbtn)) ||
9220
3/4
✓ Branch 0 taken 1956329 times.
✓ Branch 1 taken 98422 times.
✓ Branch 2 taken 1956329 times.
✗ Branch 3 not taken.
2054751 (zc_getrawkey(Skey, true)||joybtn(Sbtn)) ||
9221
3/4
✓ Branch 0 taken 1942626 times.
✓ Branch 1 taken 13703 times.
✓ Branch 2 taken 1942626 times.
✗ Branch 3 not taken.
1956329 (zc_getrawkey(Lkey, true)||joybtn(Lbtn)) ||
9222
3/4
✓ Branch 0 taken 1930532 times.
✓ Branch 1 taken 12094 times.
✓ Branch 2 taken 1930532 times.
✗ Branch 3 not taken.
1942626 (zc_getrawkey(Rkey, true)||joybtn(Rbtn)) ||
9223
3/4
✓ Branch 0 taken 1928941 times.
✓ Branch 1 taken 1591 times.
✓ Branch 2 taken 1928941 times.
✗ Branch 3 not taken.
1930532 (zc_getrawkey(Pkey, true)||joybtn(Pbtn)) ||
9224
3/4
✓ Branch 0 taken 1928889 times.
✓ Branch 1 taken 52 times.
✓ Branch 2 taken 1928889 times.
✗ Branch 3 not taken.
1928941 (zc_getrawkey(Exkey1, true)||joybtn(Exbtn1)) ||
9225
3/4
✓ Branch 0 taken 1928102 times.
✓ Branch 1 taken 787 times.
✓ Branch 2 taken 1928102 times.
✗ Branch 3 not taken.
1928889 (zc_getrawkey(Exkey2, true)||joybtn(Exbtn2)) ||
9226
2/4
✓ Branch 0 taken 1928102 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1928102 times.
✗ Branch 3 not taken.
1928102 (zc_getrawkey(Exkey3, true)||joybtn(Exbtn3)) ||
9227
2/2
✓ Branch 0 taken 1928083 times.
✓ Branch 1 taken 19 times.
1928102 (zc_getrawkey(Exkey4, true)||joybtn(Exbtn4))) // Skipping joystick axes
9228 58329583 return true;
9229
9230 1928083 return false;
9231 7521864 }
9232
9233 124696648 bool getInput(int32_t btn, bool press, bool drunk, bool ignoreDisable, bool eatEntirely, bool peek)
9234 {
9235 124696648 bool ret = false, drunkstate = false, rawret = false;
9236 124696648 bool* flag = &down_control_states[btn];
9237
2/7
✓ Branch 0 taken 117166891 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 7529757 times.
124696648 switch(btn)
9238 {
9239 case btnF12:
9240 ret = zc_getkey(KEY_F12, ignoreDisable);
9241 rawret = zc_getrawkey(KEY_F12, ignoreDisable);
9242 eatEntirely = false;
9243 break;
9244 case btnF11:
9245 ret = zc_getkey(KEY_F11, ignoreDisable);
9246 rawret = zc_getrawkey(KEY_F11, ignoreDisable);
9247 eatEntirely = false;
9248 break;
9249 case btnF5:
9250 ret = zc_getkey(KEY_F5, ignoreDisable);
9251 rawret = zc_getrawkey(KEY_F5, ignoreDisable);
9252 eatEntirely = false;
9253 break;
9254 case btnQ:
9255 ret = zc_getkey(KEY_Q, ignoreDisable);
9256 rawret = zc_getrawkey(KEY_Q, ignoreDisable);
9257 eatEntirely = false;
9258 break;
9259 case btnI:
9260 ret = zc_getkey(KEY_I, ignoreDisable);
9261 rawret = zc_getrawkey(KEY_I, ignoreDisable);
9262 eatEntirely = false;
9263 break;
9264 case btnM:
9265
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7529757 times.
7529757 if(FFCore.kb_typing_mode) return false;
9266 7529757 rawret = ret = zc_getrawkey(KEY_ESC, ignoreDisable);
9267 7529757 eatEntirely = false;
9268 7529757 break;
9269 default: //control_state[] index
9270
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 117166891 times.
117166891 if(FFCore.kb_typing_mode) return false;
9271
5/6
✓ Branch 0 taken 116902695 times.
✓ Branch 1 taken 264196 times.
✓ Branch 2 taken 2257162 times.
✓ Branch 3 taken 114645533 times.
✓ Branch 4 taken 2257162 times.
✗ Branch 5 not taken.
117166891 if(!ignoreDisable && get_bit(quest_rules, qr_FIXDRUNKINPUTS) && disable_control[btn]) drunk = false;
9272
2/2
✓ Branch 0 taken 6338332 times.
✓ Branch 1 taken 110828559 times.
117166891 else if(btn<11) drunkstate = drunk_toggle_state[btn];
9273
4/4
✓ Branch 0 taken 105659561 times.
✓ Branch 1 taken 11507330 times.
✓ Branch 2 taken 1490 times.
✓ Branch 3 taken 11505840 times.
128674221 ret = control_state[btn] && (ignoreDisable || !disable_control[btn]);
9274 117166891 rawret = raw_control_state[btn];
9275 117166891 }
9276
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 124696648 times.
124696648 assert(flag);
9277
2/2
✓ Branch 0 taken 80744761 times.
✓ Branch 1 taken 43951887 times.
124696648 if(press)
9278 {
9279
2/2
✓ Branch 0 taken 1431671 times.
✓ Branch 1 taken 42520216 times.
43951887 if(peek)
9280 1431671 ret = rButtonPeek(ret, *flag);
9281
3/4
✓ Branch 0 taken 42520216 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 22834523 times.
✓ Branch 3 taken 19685693 times.
42520216 else if (replay_is_active() && replay_get_version() < 8) ret = rButton(ret, *flag);
9282 22834523 else ret = rButton(ret, *flag, &rawret);
9283 43951887 }
9284
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 124696648 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
124696648 if(eatEntirely && ret) control_state[btn] = false;
9285
3/4
✓ Branch 0 taken 94394730 times.
✓ Branch 1 taken 30301918 times.
✓ Branch 2 taken 94394730 times.
✗ Branch 3 not taken.
124696648 if(drunk && drunkstate) ret = !ret;
9286 124696648 return ret;
9287 124696648 }
9288
9289 6162921 byte getIntBtnInput(byte intbtn, bool press, bool drunk, bool ignoreDisable, bool eatEntirely, bool peek)
9290 {
9291 6162921 byte ret = 0;
9292
2/2
✓ Branch 0 taken 4729181 times.
✓ Branch 1 taken 1433740 times.
6162921 if(intbtn & INT_BTN_A) ret |= getInput(btnA, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_A : 0;
9293
2/2
✓ Branch 0 taken 6162359 times.
✓ Branch 1 taken 562 times.
6162921 if(intbtn & INT_BTN_B) ret |= getInput(btnB, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_B : 0;
9294
2/2
✓ Branch 0 taken 6162484 times.
✓ Branch 1 taken 437 times.
6162921 if(intbtn & INT_BTN_L) ret |= getInput(btnL, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_L : 0;
9295
2/2
✓ Branch 0 taken 6162484 times.
✓ Branch 1 taken 437 times.
6162921 if(intbtn & INT_BTN_R) ret |= getInput(btnR, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_R : 0;
9296
2/2
✓ Branch 0 taken 6162484 times.
✓ Branch 1 taken 437 times.
6162921 if(intbtn & INT_BTN_EX1) ret |= getInput(btnEx1, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_EX1 : 0;
9297
2/2
✓ Branch 0 taken 6162484 times.
✓ Branch 1 taken 437 times.
6162921 if(intbtn & INT_BTN_EX2) ret |= getInput(btnEx2, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_EX2 : 0;
9298
2/2
✓ Branch 0 taken 6162484 times.
✓ Branch 1 taken 437 times.
6162921 if(intbtn & INT_BTN_EX3) ret |= getInput(btnEx3, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_EX3 : 0;
9299
2/2
✓ Branch 0 taken 6162484 times.
✓ Branch 1 taken 437 times.
6162921 if(intbtn & INT_BTN_EX4) ret |= getInput(btnEx4, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_EX4 : 0;
9300 6162921 return ret; //No early return, to make sure all button presses are eaten that should be! -Em
9301 }
9302
9303 1114 byte checkIntBtnVal(byte intbtn, byte vals)
9304 {
9305 1114 return intbtn&vals;
9306 }
9307
9308 1455707 bool Up()
9309 {
9310 1455707 return getInput(btnUp);
9311 }
9312 89081 bool Down()
9313 {
9314 89081 return getInput(btnDown);
9315 }
9316 179248 bool Left()
9317 {
9318 179248 return getInput(btnLeft);
9319 }
9320 200431 bool Right()
9321 {
9322 200431 return getInput(btnRight);
9323 }
9324 99306 bool cAbtn()
9325 {
9326 99306 return getInput(btnA);
9327 }
9328 1318258 bool cBbtn()
9329 {
9330 1318258 return getInput(btnB);
9331 }
9332 bool cSbtn()
9333 {
9334 return getInput(btnS);
9335 }
9336 40856 bool cLbtn()
9337 {
9338 40856 return getInput(btnL);
9339 }
9340 40856 bool cRbtn()
9341 {
9342 40856 return getInput(btnR);
9343 }
9344 bool cPbtn()
9345 {
9346 return getInput(btnP);
9347 }
9348 bool cEx1btn()
9349 {
9350 return getInput(btnEx1);
9351 }
9352 bool cEx2btn()
9353 {
9354 return getInput(btnEx2);
9355 }
9356 bool cEx3btn()
9357 {
9358 return getInput(btnEx3);
9359 }
9360 bool cEx4btn()
9361 {
9362 return getInput(btnEx4);
9363 }
9364 bool AxisUp()
9365 {
9366 return getInput(btnAxisUp);
9367 }
9368 bool AxisDown()
9369 {
9370 return getInput(btnAxisDown);
9371 }
9372 bool AxisLeft()
9373 {
9374 return getInput(btnAxisLeft);
9375 }
9376 bool AxisRight()
9377 {
9378 return getInput(btnAxisRight);
9379 }
9380
9381 bool cMbtn()
9382 {
9383 return getInput(btnM);
9384 }
9385 bool cF12()
9386 {
9387 return getInput(btnF12);
9388 }
9389 bool cF11()
9390 {
9391 return getInput(btnF11);
9392 }
9393 bool cF5()
9394 {
9395 return getInput(btnF5);
9396 }
9397 bool cQ()
9398 {
9399 return getInput(btnQ);
9400 }
9401 bool cI()
9402 {
9403 return getInput(btnI);
9404 }
9405
9406 120114 bool rUp()
9407 {
9408 120114 return getInput(btnUp, true);
9409 }
9410 120025 bool rDown()
9411 {
9412 120025 return getInput(btnDown, true);
9413 }
9414 119973 bool rLeft()
9415 {
9416 119973 return getInput(btnLeft, true);
9417 }
9418 119511 bool rRight()
9419 {
9420 119511 return getInput(btnRight, true);
9421 }
9422 2646 bool rAbtn()
9423 {
9424 2646 return getInput(btnA, true);
9425 }
9426 120893 bool rBbtn()
9427 {
9428 120893 return getInput(btnB, true);
9429 }
9430 6103092 bool rSbtn()
9431 {
9432 6103092 return getInput(btnS, true);
9433 }
9434 7521864 bool rMbtn()
9435 {
9436 7521864 return getInput(btnM, true);
9437 }
9438 119304 bool rLbtn()
9439 {
9440 119304 return getInput(btnL, true);
9441 }
9442 119299 bool rRbtn()
9443 {
9444 119299 return getInput(btnR, true);
9445 }
9446 6022484 bool rPbtn()
9447 {
9448 6022484 return getInput(btnP, true);
9449 }
9450 bool rEx1btn()
9451 {
9452 return getInput(btnEx1, true);
9453 }
9454 bool rEx2btn()
9455 {
9456 return getInput(btnEx2, true);
9457 }
9458 130178 bool rEx3btn()
9459 {
9460 130178 return getInput(btnEx3, true);
9461 }
9462 130178 bool rEx4btn()
9463 {
9464 130178 return getInput(btnEx4, true);
9465 }
9466 bool rAxisUp()
9467 {
9468 return getInput(btnAxisUp, true);
9469 }
9470 bool rAxisDown()
9471 {
9472 return getInput(btnAxisDown, true);
9473 }
9474 bool rAxisLeft()
9475 {
9476 return getInput(btnAxisLeft, true);
9477 }
9478 bool rAxisRight()
9479 {
9480 return getInput(btnAxisRight, true);
9481 }
9482
9483 bool rF11()
9484 {
9485 return getInput(btnF11, true);
9486 }
9487 bool rQ()
9488 {
9489 return getInput(btnQ, true);
9490 }
9491 bool rI()
9492 {
9493 return getInput(btnI, true);
9494 }
9495
9496 15284385 bool DrunkUp()
9497 {
9498 15284385 return getInput(btnUp, false, true);
9499 }
9500 14241704 bool DrunkDown()
9501 {
9502 14241704 return getInput(btnDown, false, true);
9503 }
9504 8970450 bool DrunkLeft()
9505 {
9506 8970450 return getInput(btnLeft, false, true);
9507 }
9508 7781243 bool DrunkRight()
9509 {
9510 7781243 return getInput(btnRight, false, true);
9511 }
9512 6663872 bool DrunkcAbtn()
9513 {
9514 6663872 return getInput(btnA, false, true);
9515 }
9516 6560211 bool DrunkcBbtn()
9517 {
9518 6560211 return getInput(btnB, false, true);
9519 }
9520 5981304 bool DrunkcEx1btn()
9521 {
9522 5981304 return getInput(btnEx1, false, true);
9523 }
9524 5981324 bool DrunkcEx2btn()
9525 {
9526 5981324 return getInput(btnEx2, false, true);
9527 }
9528 bool DrunkcSbtn()
9529 {
9530 return getInput(btnS, false, true);
9531 }
9532 bool DrunkcMbtn()
9533 {
9534 return getInput(btnM, false, true);
9535 }
9536 bool DrunkcLbtn()
9537 {
9538 return getInput(btnL, false, true);
9539 }
9540 bool DrunkcRbtn()
9541 {
9542 return getInput(btnR, false, true);
9543 }
9544 bool DrunkcPbtn()
9545 {
9546 return getInput(btnP, false, true);
9547 }
9548
9549 bool DrunkrUp()
9550 {
9551 return getInput(btnUp, true, true);
9552 }
9553 bool DrunkrDown()
9554 {
9555 return getInput(btnDown, true, true);
9556 }
9557 bool DrunkrLeft()
9558 {
9559 return getInput(btnLeft, true, true);
9560 }
9561 bool DrunkrRight()
9562 {
9563 return getInput(btnRight, true, true);
9564 }
9565 5007308 bool DrunkrAbtn()
9566 {
9567 5007308 return getInput(btnA, true, true);
9568 }
9569 5021777 bool DrunkrBbtn()
9570 {
9571 5021777 return getInput(btnB, true, true);
9572 }
9573 71669 bool DrunkrEx1btn()
9574 {
9575 71669 return getInput(btnEx1, true, true);
9576 }
9577 71662 bool DrunkrEx2btn()
9578 {
9579 71662 return getInput(btnEx2, true, true);
9580 }
9581 bool DrunkrEx3btn()
9582 {
9583 return getInput(btnEx3, true, true);
9584 }
9585 bool DrunkrEx4btn()
9586 {
9587 return getInput(btnEx4, true, true);
9588 }
9589 bool DrunkrSbtn()
9590 {
9591 return getInput(btnS, true, true);
9592 }
9593 bool DrunkrMbtn()
9594 {
9595 return getInput(btnM, true, true);
9596 }
9597 5662007 bool DrunkrLbtn()
9598 {
9599 5662007 return getInput(btnL, true, true);
9600 }
9601 5658890 bool DrunkrRbtn()
9602 {
9603 5658890 return getInput(btnR, true, true);
9604 }
9605 bool DrunkrPbtn()
9606 {
9607 return getInput(btnP, true, true);
9608 }
9609
9610 7893 void eat_buttons()
9611 {
9612 7893 getInput(btnA, true, false, true);
9613 7893 getInput(btnB, true, false, true);
9614 7893 getInput(btnS, true, false, true);
9615 7893 getInput(btnM, true, false, true);
9616 7893 getInput(btnL, true, false, true);
9617 7893 getInput(btnR, true, false, true);
9618 7893 getInput(btnP, true, false, true);
9619 7893 getInput(btnEx1, true, false, true);
9620 7893 getInput(btnEx2, true, false, true);
9621 7893 getInput(btnEx3, true, false, true);
9622 7893 getInput(btnEx4, true, false, true);
9623 7893 }
9624
9625 // Is true for the _first frame_ of a key press.
9626 // But! it is possible that a script manually sets the value of KeyPress,
9627 // in which case it will be restored to the "true" value based on `key_current_frame`
9628 // and `key_previous_frame` on the next frame.
9629 14 bool zc_readkey(int32_t k, bool ignoreDisable)
9630 {
9631
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(ignoreDisable) return KeyPress[k];
9632
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 switch(k)
9633 {
9634 case KEY_F7:
9635 case KEY_F8:
9636 case KEY_F9:
9637 return KeyPress[k];
9638
9639 default:
9640
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 1 times.
14 return KeyPress[k] && !disabledKeys[k];
9641 }
9642 14 }
9643
9644 // Is true for _every frame_ a key is held down.
9645 // But! it is possible that a script manually sets the value of KeyInput,
9646 // in which case it will be restored to the "true" value based on `key_current_frame`
9647 // on the next frame.
9648 bool zc_getkey(int32_t k, bool ignoreDisable)
9649 {
9650 if(ignoreDisable) return KeyInput[k];
9651 switch(k)
9652 {
9653 case KEY_F7:
9654 case KEY_F8:
9655 case KEY_F9:
9656 return KeyInput[k];
9657
9658 default:
9659 return KeyInput[k] && !disabledKeys[k];
9660 }
9661 }
9662
9663 // Reads (and then clears) the current frame key state directly.
9664 // Scripts can also modify `key_current_frame`.
9665 143 bool zc_readrawkey(int32_t k, bool ignoreDisable)
9666 {
9667
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 141 times.
143 if(zc_getrawkey(k, ignoreDisable))
9668 {
9669 2 _key[k]=key[k]=key_current_frame[k]=0;
9670 2 return true;
9671 }
9672 141 _key[k]=key[k]=key_current_frame[k]=0;
9673 141 return false;
9674 143 }
9675
9676 // Reads the current frame key state directly.
9677 // Scripts can also modify `key_current_frame`.
9678 50698799 bool zc_getrawkey(int32_t k, bool ignoreDisable)
9679 {
9680
2/2
✓ Branch 0 taken 43176907 times.
✓ Branch 1 taken 7521892 times.
50698799 if(ignoreDisable) return key_current_frame[k];
9681
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7521892 times.
7521892 switch(k)
9682 {
9683 case KEY_F7:
9684 case KEY_F8:
9685 case KEY_F9:
9686 return key_current_frame[k];
9687
9688 default:
9689
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7521892 times.
7521892 return key_current_frame[k] && !disabledKeys[k];
9690 }
9691 50698799 }
9692
9693 // Only used for a handful of keys, like tilde and Function keys.
9694 // This state is never read within the game.
9695 // It exists so that all keyboard input still functions during replay,
9696 // without inadvertently doing things like toggling throttling if the player
9697 // presses ~
9698 15043800 bool zc_get_system_key(int32_t k)
9699 {
9700 15043800 return key_system[k];
9701 }
9702
9703 // True for the _first_ frame of a key press.
9704 67696776 bool zc_read_system_key(int32_t k)
9705 {
9706 67696776 return key_system_press[k];
9707 }
9708
9709 955276728 bool is_system_key(int32_t k)
9710 {
9711
2/2
✓ Branch 0 taken 887579952 times.
✓ Branch 1 taken 67696776 times.
955276728 switch (k)
9712 {
9713 case KEY_BACKQUOTE:
9714 case KEY_CLOSEBRACE:
9715 case KEY_END:
9716 case KEY_HOME:
9717 case KEY_OPENBRACE:
9718 case KEY_PGDN:
9719 case KEY_PGUP:
9720 case KEY_TAB:
9721 case KEY_TILDE:
9722 67696776 return true;
9723 }
9724 887579952 return is_Fkey(k);
9725 955276728 }
9726
9727 7521864 void update_system_keys()
9728 {
9729
2/2
✓ Branch 0 taken 955276728 times.
✓ Branch 1 taken 7521864 times.
962798592 for (int32_t q = 0; q < 127; ++q)
9730 {
9731
2/2
✓ Branch 0 taken 157959144 times.
✓ Branch 1 taken 797317584 times.
955276728 if (!is_system_key(q))
9732 797317584 continue;
9733
9734 157959144 key_system[q] = key[q];
9735
1/2
✓ Branch 0 taken 157959144 times.
✗ Branch 1 not taken.
157959144 key_system_press[q] = key_system[q] && !key_system_previous[q];
9736 157959144 key_system_previous[q] = key_system[q];
9737 157959144 }
9738 7521864 }
9739
9740 8639330 void update_keys()
9741 {
9742
2/2
✓ Branch 0 taken 1097194910 times.
✓ Branch 1 taken 8639330 times.
1105834240 for (int32_t q = 0; q < 127; ++q)
9743 {
9744 // When replaying, replay.cpp takes care of updating `key_current_frame`.
9745
1/2
✓ Branch 0 taken 1097194910 times.
✗ Branch 1 not taken.
1097194910 if (!replay_is_replaying())
9746 key_current_frame[q] = key[q];
9747
9748
2/2
✓ Branch 0 taken 1089125613 times.
✓ Branch 1 taken 8069297 times.
1097194910 KeyPress[q] = key_current_frame[q] && !key_previous_frame[q];
9749 1097194910 KeyInput[q] = key_current_frame[q];
9750 1097194910 key_previous_frame[q] = key_current_frame[q];
9751 1097194910 }
9752 8639330 }
9753
9754 bool zc_disablekey(int32_t k, bool val)
9755 {
9756 switch(k)
9757 {
9758 case KEY_F7:
9759 case KEY_F8:
9760 case KEY_F9:
9761 return false;
9762
9763 default:
9764 disabledKeys[k] = val;
9765 return true;
9766 }
9767 }
9768
9769 void zc_putpixel(int32_t layer, int32_t x, int32_t y, int32_t cset, int32_t color, int32_t timer)
9770 {
9771 timer=timer;
9772 particles.add(new particle(zfix(x), zfix(y), layer, cset, color));
9773 }
9774
9775 // these are here so that copy_dialog won't choke when compiling zelda
9776 int32_t d_alltriggerbutton_proc(int32_t, DIALOG*, int32_t)
9777 {
9778 return D_O_K;
9779 }
9780
9781 int32_t d_comboa_radio_proc(int32_t, DIALOG*, int32_t)
9782 {
9783 return D_O_K;
9784 }
9785
9786 int32_t d_comboabutton_proc(int32_t, DIALOG*, int32_t)
9787 {
9788 return D_O_K;
9789 }
9790
9791 int32_t d_ssdn_btn_proc(int32_t, DIALOG*, int32_t)
9792 {
9793 return D_O_K;
9794 }
9795
9796 int32_t d_ssdn_btn2_proc(int32_t, DIALOG*, int32_t)
9797 {
9798 return D_O_K;
9799 }
9800
9801 int32_t d_ssdn_btn3_proc(int32_t, DIALOG*, int32_t)
9802 {
9803 return D_O_K;
9804 }
9805
9806 int32_t d_ssdn_btn4_proc(int32_t, DIALOG*, int32_t)
9807 {
9808 return D_O_K;
9809 }
9810
9811 int32_t d_sslt_btn_proc(int32_t, DIALOG*, int32_t)
9812 {
9813 return D_O_K;
9814 }
9815
9816 int32_t d_sslt_btn2_proc(int32_t, DIALOG*, int32_t)
9817 {
9818 return D_O_K;
9819 }
9820
9821 int32_t d_sslt_btn3_proc(int32_t, DIALOG*, int32_t)
9822 {
9823 return D_O_K;
9824 }
9825
9826 int32_t d_sslt_btn4_proc(int32_t, DIALOG*, int32_t)
9827 {
9828 return D_O_K;
9829 }
9830
9831 int32_t d_ssrt_btn_proc(int32_t, DIALOG*, int32_t)
9832 {
9833 return D_O_K;
9834 }
9835
9836 int32_t d_ssrt_btn2_proc(int32_t, DIALOG*, int32_t)
9837 {
9838 return D_O_K;
9839 }
9840
9841 int32_t d_ssrt_btn3_proc(int32_t, DIALOG*, int32_t)
9842 {
9843 return D_O_K;
9844 }
9845
9846 int32_t d_ssrt_btn4_proc(int32_t, DIALOG*, int32_t)
9847 {
9848 return D_O_K;
9849 }
9850
9851 int32_t d_ssup_btn_proc(int32_t, DIALOG*, int32_t)
9852 {
9853 return D_O_K;
9854 }
9855
9856 int32_t d_ssup_btn2_proc(int32_t, DIALOG*, int32_t)
9857 {
9858 return D_O_K;
9859 }
9860
9861 int32_t d_ssup_btn3_proc(int32_t, DIALOG*, int32_t)
9862 {
9863 return D_O_K;
9864 }
9865
9866 int32_t d_ssup_btn4_proc(int32_t, DIALOG*, int32_t)
9867 {
9868 return D_O_K;
9869 }
9870
9871 int32_t d_tri_edit_proc(int32_t, DIALOG*, int32_t)
9872 {
9873 return D_O_K;
9874 }
9875
9876 int32_t d_triggerbutton_proc(int32_t, DIALOG*, int32_t)
9877 {
9878 return D_O_K;
9879 }
9880
9881 /*** end of zc_sys.cc ***/
9882
9883